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

VS 2012 How to stop new line overwriting all existing text in text file?

$
0
0
When I add a new record to the Listbox from textboxes - it replaces my original text in the text file. :confused:
Any ideas on why? This is what I've got...

Code:

Private Sub cmdAdd_Click(sender As Object, e As EventArgs) Handles cmdAdd.Click

        Dim UpdateCustomerFile As New System.IO.StreamWriter("C:\Users\tabitha.vockler\Documents\Customers.txt")
        Dim UpdateRecord As String

        UpdateRecord = txtFirstName.Text + "," + txtSurname.Text + "," + txtMobile.Text + "," + cboDiscount.Text

        UpdateCustomerFile.WriteLine(UpdateRecord)

        UpdateCustomerFile.Close()

        My.Computer.FileSystem.OpenTextFileReader("C:\Users\tabitha.vockler\Documents\Customers.txt")

        Dim A() As String = IO.File.ReadAllLines("C:\Users\tabitha.vockler\Documents\Customers.txt")
        For Each Content As String In A
            lstCustomers.Items.Add(Content)
        Next

    End Sub


Viewing all articles
Browse latest Browse all 42220

Trending Articles



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