In the below snippet code covered following actions.
1. Create a text file with “FilesytemObject”(Note pad) object.
2. Enter text in to the text file and close it.
3. Open the same and read the data .
Const ForReading = 1, ForWriting = 2
Dim fso, MyFile,a, intLine
' Create Object
Set fso = CreateObject("Scripting.FileSystemObject")
' Create file and enter data into the created file
Set MyFile = fso.OpenTextFile("c:\SuryaRead1.txt", ForWriting, True)
MyFile.WriteLine "Hello world!"
MyFile.WriteLine "Quick Test Pro "
' Close the file
MyFile.Close
' Open the file for reading
Set MyFile = fso.OpenTextFile("c:\SuryaRead.txt", ForReading,True)
For i = 1 to 2
a = MyFile.ReadLine ' Returns text line by line
MsgBox a
Next
Friday, February 13, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment