Zebra0.com

visual-basic listmanager

We will use a global variable changed that is Boolean. Intitially, we will set it to false. We will change the value under the following conditions:

Add changed= True to each of these procedures:

Private Sub mnuInsert_Click(sender As Object, e As EventArgs) Handles mnuInsert.Click
  'Add an item to the list box
  Dim s As String
  s = InputBox("Enter item", "Add Item")
  If s <> "" Then
    ListBox1.Items.Add(s)
    changed = True
  End If
End Sub

Private Sub mnuDelete_Click(sender As Object, e As EventArgs) Handles mnuDelete.Click
  'Delete if there are items and one is selected
  If ListBox1.Items.Count > 0 And ListBox1.SelectedIndex >= 0 Then
     ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
     changed = True
  Else
    ListBox1.Text = ""
  End If
  If ListBox1.Items.Count > 0 Then
     ListBox1.SelectedIndex = 0
  End If
End Sub    

Add changed= False to each of this procedures:

Private Sub mnuSave_Click(sender As Object, e As EventArgs) Handles mnuSave.Click
    SaveList()
    changed = False
End Sub

NEXT: Build the Menu