Click to See Complete Forum and Search --> : Reading Line by line
BMLekki
June 13th, 2001, 01:48 PM
I want to read Line by Line from a txt file useing the FileSystemObject. When i use .ReadLine
my string still contains all of what was in the txt file. Once i get one line i want to write it to another file and then go back the txt file to read a new line. Any Ideas??
BMLEKKI@BPAS.COM
ecannizzo
June 13th, 2001, 01:49 PM
Can we see the code?
BMLekki
June 13th, 2001, 01:52 PM
private Sub cmdReadFile_Click()
Dim InStream as TextStream
BodyText = App.Path & "\body.txt"
set InStream = FSys.OpenTextFile(BodyText, 1, false, false)
While InStream.AtEndOfStream = false
TLine = InStream.ReadAll
strBody = strBody & TLine & vbCrLf
Wend
' Text1.Text = strBody
set InStream = nothing
Dim AddressInStream as TextStream
AddressText = App.Path & "\email.txt"
set AddressInStream = FSys.OpenTextFile(AddressText, 1, false, false)
While AddressInStream.AtEndOfStream = false
TLine = AddressInStream.ReadLine
strAddress = strAddress & TLine & vbCrLf
Wend
Text1.Text = strAddress & strBody
set AddressInStream = nothing
End Sub
BMLekki
June 13th, 2001, 01:54 PM
email.txt
looks like this
test@abc.com
test@xyz.net
with about 200 address.
ecannizzo
June 13th, 2001, 02:03 PM
Every time you say this:
strAddress = strAddress & TLine & vbCrLf
It is appending the new stuff to the old stuff. You need to just use:
strAddress = TLine & vbCrLf
HTH,
Erica
BMLekki
June 13th, 2001, 02:11 PM
strAddress = TLine & vbCrLf
This only gives me the last line in the email.txt.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.