Tuesday, 3 March 2020

VB6 Program to read/write text file using filesystemobject



Program to read/write text file using filesystemobject

Private Sub Command2_Click()
'read text file and print

Dim fs As FileSystemObject
Dim ts As TextStream

Set fs = New FileSystemObject
If fs.FileExists("C:\Users\Desktop\text1.txt") Then
    Set ts = fs.OpenTextFile("C:\Users\Desktop\text1.txt", ForReading, True)
    Do While Not ts.AtEndOfStream
        strnewlines = strnewlines & ts.ReadLine & vbCrLf

    Loop
    ts.Close
End If

'for writing into text file
Set ts = fs.OpenTextFile("C:\Users\Desktop\text2.txt", ForWriting, True)
ts.Write strnewlines

End Sub

No comments:

Post a Comment

VBScript: How to use Dictionary in VBScript | VBScript objects

=>To declare and create object of a vbscript dictionary: Dim objDictionary Set objDictionary = CreateObject("Scripting.Dictionar...