title: vb.net Save/Load file and other issues
body: <p>I'm creating a simple program that could be used to save contacts and information on its contact. I have trouble with the <strong>save/load</strong> functions and the <strong>total count</strong> of inserted contacts. Most code is taken from a tutorial of "TheNewBoston" and since I liked it I try to add more features. Here is the source code:</p>
  
  <pre><code>Public Class Form1
  
      Dim myCustomers As New ArrayList
      Dim FILE_NAME As String = "C:\test.txt"
  
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
          AddCustomer("Sam", "Bond", "sambond@msn.com", "9541032163")
          AddCustomer("Merry", "Jackson", "merryjackson@msn.com", "8872101103")
          AddCustomer("Rachel", "Smith", "rachelsmith@msn.com", "4839078565")
          'DOESN'T WORK''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
          If System.IO.File.Exists(FILE_NAME) = True Then
              'AddCustomer.System.IO.StreamReader(FILE_NAME)
              'or
              AddCustomer(System.IO.StreamReader(FILE_NAME))
          Else
              MessageBox.Show("File does not exist.")
          End If
      End Sub
  
      'Public variables
      Private Structure Customer
          Public FirstName As String
          Public LastName As String
          Public Email As String
          Public Phone As Decimal
  
          'Does Name = First&amp;Last Name
          Public ReadOnly Property Name() As String
              Get
                  Return FirstName &amp; " " &amp; LastName
              End Get
          End Property
  
          'Shows the customers in the listbox properly overriding the default ToString function
          Public Overrides Function ToString() As String
              Return Name
          End Function
  
      End Structure
  
      'Declaring and connecting to type Customer
      Private objCustomer As Customer
      Private objNewCustomer As Customer
  
      'Makes customer format
      Private Sub AddCustomer(ByVal firstName As String, ByVal lastName As String, ByVal email As String, ByVal phone As Decimal)
          'declares objNewCustomer with the type of customer for use
          Dim objNewCustomer As Customer
  
          'Connects the Customer's 4 things to objNewCustomer
          objNewCustomer.FirstName = firstName
          objNewCustomer.LastName = lastName
          objNewCustomer.Email = email
          objNewCustomer.Phone = phone
  
          'Adds to myCustomers array list the objNewCustomer
          myCustomers.Add(objNewCustomer)
          'Adds customer Name to list
          listCustomers.Items.Add(objNewCustomer.ToString())
      End Sub
  
      'Avoids customer select error
      Private ReadOnly Property SelectedCustomer() As Customer
          Get
              If listCustomers.SelectedIndex &lt;&gt; -1 Then
                  Return CType(myCustomers(listCustomers.SelectedIndex), Customer)
              End If
          End Get
      End Property
  
      'Enables select customer
      Private Sub listCustomers_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles listCustomers.SelectedIndexChanged
          DisplayCustomer(SelectedCustomer)
      End Sub
  
  
      'Loads the customers' information
      Private Sub DisplayCustomer(ByVal cust As Customer)
          txtName.Text = cust.Name
          txtFirstName.Text = cust.FirstName
          txtLastName.Text = cust.LastName
          txtEmail.Text = cust.Email
          txtPhone.Text = cust.Phone
      End Sub
  
  
      'Add User (pops up new window)
      Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
          Form2.Show()
          'System.IO.File.WriteAllText("C:\test.txt", Textbox1.Text)
      End Sub
  
      'WORKS
      Private Sub btnTotal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTotal.Click
          txtTotal.Text = myCustomers.Count.ToString()
      End Sub
  
      'Private Total2 As Integer
      'experimenting
      'Private Sub DisTotal(ByVal Total As Integer)
      '    Do
      '        'total2 = myCustomers.Count.ToString()
      '        'txtTotal.Text = total2
      '        txtTotal.Text = Total
      '        System.Threading.Thread.Sleep(5000)
      '    Loop
      'End Sub
  
      Private Sub listTotal_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
          Total = myCustomers.Count
          'DOESN'T WORK''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
          Do
              'total2 = myCustomers.Count.ToString()
              'txtTotal.Text = total2
              txtTotal.Text = myCustomers.Count.ToString()
              System.Threading.Thread.Sleep(5000)
          Loop
      End Sub
  
      Private Total As Integer
      'DOESN'T WORK''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
          Dim writer As New IO.StreamWriter(FILE_NAME)
  
          Try
              writer.Write("")
              writer.Close()
          Catch ex As Exception
              MessageBox.Show(ex.Message)
          Finally
              writer.Close()
          End Try
      End Sub End Class
  </code></pre>
  
  <p>Any help/hint appreciated and also if you post corrected code blocks please explain how it works/what was wrong too, thanks.</p>