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

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)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.