eneate
asked on
How do I write text data to a text box instead of a text file?
Hi
I have been outputting data to a txt file which works fine. But rather than a txt file I need to use an open window with a text box. Lines of text are continually entered one at a time.
I use the following to open the file and write the data
Public Function WriteLineToFile(ByVal filename As String, ByVal outputLine As String)
On Error GoTo fileError
Dim ff As Integer
ff = FreeFile
Open filename For Append As #ff
Print #ff, outputLine
Close #ff
Exit Function
fileError:
MsgBox "Error writing to " & filename & vbCrLf & err.Description, vbExclamation, "Error " & err.Number
End Function
and the following under the click button
WriteLineToFile outputlog, "Logged on user:" & " " & name & " " & Date & " " & Time & " " & "FFT" & " " & "Image Name:" & " " & imagename
Here output log is a file, I want to change it to a text box. I have tried but keep getting errors
Experts can you help?
I have been outputting data to a txt file which works fine. But rather than a txt file I need to use an open window with a text box. Lines of text are continually entered one at a time.
I use the following to open the file and write the data
Public Function WriteLineToFile(ByVal filename As String, ByVal outputLine As String)
On Error GoTo fileError
Dim ff As Integer
ff = FreeFile
Open filename For Append As #ff
Print #ff, outputLine
Close #ff
Exit Function
fileError:
MsgBox "Error writing to " & filename & vbCrLf & err.Description, vbExclamation, "Error " & err.Number
End Function
and the following under the click button
WriteLineToFile outputlog, "Logged on user:" & " " & name & " " & Date & " " & Time & " " & "FFT" & " " & "Image Name:" & " " & imagename
Here output log is a file, I want to change it to a text box. I have tried but keep getting errors
Experts can you help?
ASKER
That works. I have it behind a command button when the button is clicked the text is added to the box. However liek this it only enter the line onnce. Every time the button is clicked I need it to go to the next line and print the same thing again. It is to be used as a image history.
Thanks
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks that works. Is there a way to make it so that the user can not deleate or edit the text. Read only
yes
in code:
text1.locked = true
in properties:
set the option locked from text 1 to true
ASKER
Thank very much it works very well.
thanks for the points, and happy coding!
textBox1.Text = textBox1.Text & "Logged on user:" & " " & name & " " & Date & " " & Time & " " & "FFT" & " " & "Image Name:" & " " & imagename