I.T. Discussion Community!
-Collapse +Expand
VB Classic
Search VB Classic Group:

Advanced
-Collapse +Expand VB Classic Store

Prestwood eMagazine

September Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyVisual Basic Classic BoardVB Classic Other Topic   Print This     

simple code problem

simple code problem in VB Classic Other topic (part of our Visual Basic Classic group).

Quick Search: problem   simple code   simple code problem  
Donnaa5dcp
Lincs
making a word processor, one button is named"Open" button, this opens a text file. After adding the CommonDialog1, the code entered:

Private Sub cmdOpen_Click()
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
End Sub

is suppposed to open a .txt file. I had a text file to test, and the text becomes the path to my file, ie C:/Ccourse1/test.txt instead of the actual text held in the file
Please help ASAP
 Posted 17 years ago (Thread Starter)
Comment Quote
About Donnaa5dcp -Collapse +Expand
Visit Profile
Membership pending.
Member subscribes to this thread but email is NOT VERIFIED.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #6989, 2 replies
Thread Started 7/15/2002 12:13:00 PM
View Counter=2849
Last Reply Posted 10/11/2002 12:43:00 AM)
Location=Lincs  
Joined=17 years ago   MB Posts=3  
maxstam
 (Inactive)
manypeaks australia
Gidday Donnaa
this is a bit of code that opens either .txt or .quiz files

Private sub OpenQuiz()
Dim i As Long 'declare a variable for iteration
Dim dummy As String
Dim sFile As String
With dlgCommonDialog
.DialogTitle = "Open"
.CancelError = False
.Filter = "Quiz Files (*.quiz)|*.quiz|Text Files (*.text)|*.text|Text Files (*.txt)|*.txt"
.ShowOpen
If Len(.FileName) = 0 Then
Exit Sub
End If
sFile = .FileName
End With

Open sFile For Input As #1

ReDim Record(200) 'set up an array for 200 records
i = 0
Do While Not EOF(1)
Line Input #1, dummy
Record(i) = dummy
Debug.Print Record(i)
i = i + 1
Loop
ReDim Preserve Record(i - 1) ' redimension the array to the number of items
Close #1
End Sub
 Posted 17 years ago
Comment Quote
About maxstam -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #6994 (Level 1.1)  Reply to 6989
Thread Started 7/16/2002 5:39:00 AM
View Counter=2
Location=manypeaks australia  
Joined=18 years ago   MB Posts=6  
Most Recent Post
RobZ
 (Inactive)
JHB, South Africa
The CommonDialog Control will return the NAME of the file you have selected,

Open the file using the File SystemObject as Follows ( you have to have added a ref to the Windows Scripting Runtime - NB! )

set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile( FileName , For Appending, False)
'get File's Text
MyTextBox.text = ts.readall
'Close Text Stream
ts.close
Warning - This will read the entire file into memory (watch out for those 5Gb Lists! Big Grin!

You can however read the file in line by line by using the
while not ts.endoftextStream
myLine = ts.readline
wend
Hope This Helps
 Posted 17 years ago
Comment Quote
About RobZ -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #7881 (Level 1.2)  Reply to 6989
Reply Posted 10/11/2002 12:43:00 AM
Location=JHB, South Africa  
Joined=18 years ago   MB Posts=9  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1173A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #6989 Counter
2849
Since 4/2/2008

Follow PrestwoodBoards on: 


©1995-2019 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech