Appending to files in VB
If you write any text to the file using write method, the file will be overwritten. In order to append the text to the existing text the Append method is used. This code opens test.txt and adds a entry to the end of a file.
Dim nFileNum As Integer
‘ Get a free file number
nFileNum = FreeFile
‘ Open Test.txt for append
Open App.Path & “c:\test.txt” For Append As nFileNum
‘ Add the contents of TextBox1 to Test.txt
Print #nFileNum, TextBox1.Text
‘ Close the file
Close nFileNum
Thus the contents of TextBox1.Text is appended to the test.txt file.
