0

Hello, I am a student in a VB2008 class. I am using this code to copy data in a textbox to a text file. I have several forms to copy data from. Can this be done or do I need to do each form seperately?

Dim FILE_NAME As String = "C:\test2.text"
My.Computer.FileSystem.WriteAllText(FILE_NAME,txtelectronic.text,True)
MsgBox("Text written to file")
End If
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by GeekByChoiCe
0

question is you wanna save the content of your textboxes from your different forms to the same time.
if not then i would suggest to create a Module in your project and add following function:

Friend Sub writeToFile(ByVal txt as String)
Dim FILE_NAME As String = "C:\test2.text"
My.Computer.FileSystem.WriteAllText(FILE_NAME,txt & vbnewline,True)
MsgBox("Text written to file")
End If

and each time you need to save the textbox content you call :
writeToFile(TextBox1.Text)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.