Link to home
Start Free TrialLog in
Avatar of eneate
eneateFlag for United Kingdom of Great Britain and Northern Ireland

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?
Avatar of StillUnAware
StillUnAware
Flag of Lithuania image

First of all You have to create a form and add a TextBox to it, then add text to it

textBox1.Text = textBox1.Text & "Logged on user:" & "  " & name & "  " & Date & "  " & Time & "  " & "FFT" & " " & "Image Name:" & "  " & imagename
Avatar of eneate

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
ASKER CERTIFIED SOLUTION
Avatar of Mark_FreeSoftware
Mark_FreeSoftware
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of eneate

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
Avatar of eneate

ASKER

Thank very much it works very well.

thanks for the points, and happy coding!