|
-
Jul 15th, 2000, 10:41 AM
#1
Thread Starter
Fanatic Member
Hey all,
I am trying to figure out the open command.
could someone give me the simplest example of how to use this?
I would like to open a .txt file and display it on my form.
thanks
-
Jul 15th, 2000, 10:57 AM
#2
Fanatic Member
Code:
Open "C:\MyTextFile.txt" For Input As #1
Text1.Text = Input(LOF(1),#1)
Close #1
I'm not sure about the correct syntax, but I'm quite sure it will work (NOTE: you should use FreeFile property instead of #1 thing)
HTH
(change: Use LOF instead of EOF)
[Edited by QWERTY on 07-15-2000 at 12:02 PM]
-
Jul 15th, 2000, 10:58 AM
#3
Code:
Dim strTemp As String
Open "C:\txt.txt" For Input As #1
Do Until EOF(1) = True
Line Input #1, strTemp
If Text1.Text = "" Then
Text1.Text = strTemp
Else
Text1.Text = Text1.Text & vbCrLf & strTemp
End If
Loop
Close #1
-
Jul 15th, 2000, 10:59 AM
#4
New Member
I think this is what you mean
open "c:\text.txt" for input as #1 'Open the file
do
line input #1, textline 'Get one line of text
print textline 'Print the line of txt
'on your form
loop until eof(1) 'Do until end of file
close #1
That should work. I just made it here so there might be some small bugs but I think you understand the code.
Worf
-
Jul 15th, 2000, 11:21 AM
#5
hint:
in a do-loop block, always put the decision clause after the Do word, unless you want to force it to run through the code at least once.
-
Jul 15th, 2000, 01:02 PM
#6
New Member
K. Thanks wossname I'll remember that.
-
Jul 15th, 2000, 05:14 PM
#7
Addicted Member
I'm using a Rich TextBox and the command
Text1.Loadfile "C:\textfile.txt"
And for saving
Text1.Savefile "C:\textfile.txt"
Th string "C:\textfile.txt" can of course be substituted with a string variable.
Pentax
Wilhelm Tunemyr,
Swede in London
[email protected]
"Dort, wo man Bücher verbrennt, verbrennt man am Ende auch Menschen"
Heinrich Heine (1797-1856)
Pravda vítezi!
(Truth prevails!)
-
Jul 15th, 2000, 06:21 PM
#8
Qwerty, regarding your post. It is not necessary to change LOF to EOF. LOF is the one you should use in this case.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|