Please check the following function which reads all contents from a file:
Function ReadAllTextFile
Const ForReading = 1, ForWriting = 2
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\testfile.txt", ForWriting, True)
f.Write "Hello world!"
Set f = fso.OpenTextFile("c:\testfile.txt", ForReading)
ReadAllTextFile = f.ReadAll
End Function
To read line by line you can use
Do While theFile.AtEndOfStream = false
retstring = theFile.ReadLine 'This will give u single line.
Loop
Om Prakash
|