I seem to remember with DOS basic that you could read a large block of text into a variable in one go without reading each line in turn with a Line Input # loop and a Stream.
(not binary)
Can't seem to find how to do this in VB6.
Any suggestions?
Or the FileSystemObject's TextStream's ReadAll method.
Mind you, given the continued lack of feedback in your other threads I'm assuming that you must still be away from your VB computer, however , and therefore that neither of these answers will be of any use for several weeks.
strongm is correct - in fact it will be some time before I get back but that doesn't stop me thinking!
I even designed a smell app in my head the other day.
Actually I am on my way to Canada and the USA and won't get back to the land of the really free until mid October.
But don't worry, my neighbor is feeding my kangaroo.
Just to mention an alternative, you can read the file for binary input as well.
___
[tt]
Dim Contents As String, FileNum As String
FileNum = FreeFile
Open "C:\test.xml" For Binary Access Read As FileNum
Contents = Space$(LOF(FileNum))
Get #FileNum, , Contents
Close #FileNum[/tt]
___
The important thing is, it is much better and efficient to read the file this way (unless the text file is extremely large), because in this way, the read operation is performed only once.
On the other hand, with Line Input statement, the hard disk is scratched every time a read operation is requested and overall time is also increased.
The time required to read 1 KB of data, 1000 times is much larger than the time required to read 1 MB of data in a single chunk.
After reading the contents, you can also parse the contents line-by-line by performing [tt]Split[/tt] on the received text.
>considering you would have to parse the output to turn it back to text?
Not necessarily. Depends on whether the source file is ANSI or UTF. If it is a text file you've created yourself from another VB program, then it'll (almost certainly) not need parsing at all. If it is created by Notepad, then it won't need parsing. If it is a typical application log file, then it won't need parsing.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.