My latest project requires accessing text files from the user's hard drive for appending. Actually I want the user to be able to add lines of text to an existing file from data he needs which he accesses from from my server.
I have tried everything I can think of but can't seem to get the contents of a file loaded into the text box for appending.
This is my latest effort. It raises no error, so I guess the syntax is correct, but when I run the program the text box remains blank.
Public Function ReadTextFileContents(filename As String) As String
Dim fnum As Integer, isOpen As Boolean
On Error GoTo Error_Handler
fnum = FreeFile()
Open filename For Append As #fnum
isOpen = True
ReadTextFileContents = Append(LOF(fnum), fnum)
Error_Handler:
If isOpen Then Close fnum
If Err Then Err.Raise Err.Number, , Err.Description
End Function
Text1.Text = ReadTextFileContents("C:\VISUAL BASIC FILES\VB98\VB6 projects\FILEOPENTEST\FileTest.rtf"
Any suggestions would help.
Thanks,
Dwight
I have tried everything I can think of but can't seem to get the contents of a file loaded into the text box for appending.
This is my latest effort. It raises no error, so I guess the syntax is correct, but when I run the program the text box remains blank.
Public Function ReadTextFileContents(filename As String) As String
Dim fnum As Integer, isOpen As Boolean
On Error GoTo Error_Handler
fnum = FreeFile()
Open filename For Append As #fnum
isOpen = True
ReadTextFileContents = Append(LOF(fnum), fnum)
Error_Handler:
If isOpen Then Close fnum
If Err Then Err.Raise Err.Number, , Err.Description
End Function
Text1.Text = ReadTextFileContents("C:\VISUAL BASIC FILES\VB98\VB6 projects\FILEOPENTEST\FileTest.rtf"
Any suggestions would help.
Thanks,
Dwight