Re: reading form text file
See if this code helps out.. it is based on the Windows Script Host object FileSystemObject.
Dim fso
Dim myfile
set fso = CreateObject("scripting.filesystemobject") 'create the FileSystemObject
set myfile = fso.opentextfile("c:\test.txt") 'use path to your text file
sLine = Trim(myfile.readline) 'read the first line
MsgBox sLine 'show me the money
To read multiple lines, just put the code with the ReadLine method in a loop and your file should be read sequentially.
I just tested it to make sure that it will read through commas and it worked just fine. Hope that helps!
Re: reading form text file
Thank you very much.
Regards
Valery Iskarov Nikolov
http://listen.to/quark
Re: reading form text file
I haven't tested this code to make sure it runs through commas, but i think it should... this is if you prefer using the...
Open "File" for input as #1
...method of file reading, this code should do the trick.
Open "c:\test.txt" for input as #1 'open it up
Line input #1, txt 'read the first line
MsgBox txt 'show me some more of the money
Re: reading form text file
That was the first I tried but it wouldnt read through commas. Input statement treats commas like separator...
I think file system object will do it.
Valery Iskarov Nikolov
http://listen.to/quark
Re: reading form text file
line input #1, oneLine
where oneLine is a string variable.
Re: reading form text file
Were you using "Input" or "Line Input" to read the lines before? Line Input reads through to the line feed.
Re: reading form text file
Thanks, Line Input # Statement did the job perfectly.
Regards
Valery Iskarov Nikolov
http://listen.to/quark
Re: reading form text file
thanks,
I did'n notice the difference between "line input" and "input" statements
regards,
Valery Iskarov Nikolov
http://listen.to/quark