The difference between AtEndOfline and AtEndOfstream is :
AtEndOfline reads till it encounters a new line.
AtEndOfstream reads till end of the file.
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile= fso.CreateTextFile("C:\TEMP\testfile.txt", True)
MyFile.WriteLine("This is a test1.")
MyFile.WriteLine("This is a test2."+vbnewline)
MyFile.WriteLine("This is a test3.")
MyFile.Close
AtEndOfline
Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
Set theFile = fso.OpenTextFile("C:\TEMP\testfile.txt", ForReading, False)
Do While theFile.AtEndOfline <> True
MSGBOX theFile.Readline
Loop
theFile.Close
returns the output as
This is a test1.
This is a test2.
AtEndOfStream
Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
Set theFile = fso.OpenTextFile("C:\TEMP\testfile.txt", ForReading, False)
Do While theFile.AtEndOfstream <> True
MSGBOX theFile.Readline
Loop
theFile.Close
returns the output as
This is a test1.
This is a test2.
This is a test3.
Subscribe to:
Post Comments (Atom)
The difference between AtEndOfline and AtEndOfstream is :
ReplyDeleteAtEndOfline reads till it encounters a new line.
AtEndOfstream reads till end of the file.