Thorin
January 31st, 2000, 03:42 PM
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
Thorin
|
Click to See Complete Forum and Search --> : Strings Thorin January 31st, 2000, 03:42 PM 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 Johnny101 January 31st, 2000, 03:51 PM 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 codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |