|
-
January 31st, 2000, 04:42 PM
#1
Strings
Hey, I'm just wondering how i can make my program read 1 line at a time into a string from either a file or from another text box. Any help would be appreciated. Thanx,
Thorin
-
January 31st, 2000, 04:51 PM
#2
Re: Strings
Well, there are a couple of ways of doing this...
Using VB 5, you would probably do something like this:
Sub ReadFile(fn as string)
dim i as integer
dim sCurrentLine as string
i = FreeFile
Open fn for Output as i
While Not EOF(#i)
Line input #i, sCurrentLine
MsgBox sCurrentLine
Wend
Close i
End Sub
In VB 6:
set a reference to the Microsoft Scripting Runtime then paste this code somewhere:
Sub ReadFile(fn as string)
dim FSO as Scripting.FileSystemObject
Dim objReader as Scripting.TextStream
set FSO = new Scripting.FileSystemObject
set objReader = FSO.OpenTextFile(fn,ForReading,false)
While Not objReader.AtEndOfStream
MsgBox objReader.ReadLine
Wend
objReader.Close
set objReader = nothing
set FSO = nothing
End Sub
Or something like that.
Hope that helped,
John
John Pirkey
MCSD
www.ShallowWaterSystems.com
John Pirkey
MCSD (VB6)
http://www.stlvbug.org
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
|