Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42220

Continue to a text file

$
0
0
Hi guys!

Let's say I have a form with Textbox1 "Name", Textbox2 "Surname" and Textbox3 "Company".
And I have this code for Button1:
Code:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim FILE_NAME As String = "D:\test2"

        If System.IO.File.Exists(FILE_NAME) = True Then

            Dim objWriter As New System.IO.StreamWriter(FILE_NAME)

            objWriter.Write(TextBox1.Text & " ")
            objWriter.Write(TextBox2.Text & " ")
            objWriter.Write(TextBox3.Text)
            objWriter.Close()
            MsgBox("Text written to file")
        Else
            MsgBox("File Does Not Exist")
        End If
End Sub

Now, for example, if I write George, Harrison, Beatles to the textboxes, it is being written "George Harrison Beatles" to the first line of document called "text".
But next time if I run the form and fill like James, Hetfield, Metallica it is being written "James Hetfield Metallica" to the first line of document again.

What I want is to continue from the next line with keeping the previous data.

Thanks a lot!

Viewing all articles
Browse latest Browse all 42220

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>