User FAQs
If you have a question, please send it to us.
1) How can I compare text files ?
Save the two files into the same folder and open VS Code and select (File > Open Folder).
Browse to the folder and select one of the files.
Right mouse click and choose "Select for Compare".
Select the other file.
Right mouse click and choose "Compare with Selected".
If they are BAS files you may heve to Find (\") and replace with (").
2) What function would you use to determine if a file exists ?
You can use the DIR function to try to return the name of a file or directory.
If (VBA.Dir("C:\temp\myfile.xla") <> VBA.Constants.vbNullString) Then
Call VBA.MsgBox("Exists")
End If
You could also use the Microsoft.Scripting.Runtime library.
Set fso = New Scripting.FileSystemObject
If (fso.FileExists("C:\temp\myfile.txt") = True) Then
Call VBA.MsgBox("Exists")
End If
3) Write code to write data to a text file using a TextStream ?
Dim fso As Scripting.FileSystemObject
Dim txTextStream As Scripting.TextStream
Set fso = New Scripting.FileSystemObject
Set txTextStream = fso.CreateTextFile("C:\temp\myfile.txt", True)
txTextStream.Write("some text")
txTextStream.WriteBlankLines(2)
txTextStream.WriteLine("some more text")
txTextStream.Close
Set txTextStream = Nothing
Set fso = Nothing
4) Write code to read data from a text file using a TextStream ?
Dim sMyText As String
Dim sMyText2 As String
If (fso.FileExists("C:\temp\myfile.text") = False) Then Exit Sub
Set txTextStream = fso.OpenTextFile("C:\temp\myfile.txt", _
ForReading, True, TriStateUseDefault)
Do Until (txTextStream.AtEndOfStream = True)
sMyText = sMyText & txTextStream.ReadLine
Loop
sMyText2 = txTextStream.ReadAll
Debug.Print sMyText = sMyText2 'True
txTextStream.Close
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext