Read All Data From A Text File
Is there an easy way to read all the data in a text file into a string, without looping and
reading each line to build the string? I thought you could do it with the FileSystemObject but
I can't seem to find how.
Thanks for any help.
Kris
Software Engineer
Phoenix,AZ
Re: Read All Data From A Text File
you can use a stream object and issue a ReadText. The stream object is available is you are using ADO 2.6
dim str as string
Dim ts as Stream
set ts = new Stream
ts.LoadFromFile {filename}
str = ts.readtext
set ts = nothing
Re: Read All Data From A Text File
The following sample will read a text file into a variable called Text1.text
' Read a file into a TEXT box using binary read
' this reduces the exposure of VB editing double quote marks and
' commas out of the text
private Sub Command1_Click()
Dim a
a = "C:\to DO LIST\1.txt"
Open a for binary as #1
Text1.Text = input(FileLen(a), #1)
Close
End Sub
John G