Files in Visual Basic

We will use a menu strip to add buttons for Exit, Add, Delete, and Save.

menuAdd a MenuStrip menu stripto the form. After you add the menu strip, you will see the menu strip with the words "Type here."

menu2Type E&xit in the area and you will see two new boxes with the words "Type Here." The one below it is for a sub-menu, the one next to it is for a top level menu item. Continue to add top level menu items &Add, &Delete, and &Save.

menu3Select the top level menu item, Exit and change the name from ExitToolStripMenuItem to MnuExit. Do the same to name the top level menu items MnuAdd, MnuDelete and MnuSave.

We will use general procedures to add, save, and delete so that we can call them from a toolbar later.

Add gets an item from the user with an input box. The item is added only if it is not already in the combo box. After an item is added it is displayed in the text of the combo box. Add the code below to call AddItem when MnuAdd is clicked.
Private Sub MnuAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MnuAdd.Click
End Sub 'MnuAdd_Click

Public Sub AddItem()
  Dim Item As String
  Dim P As Integer
  Item = InputBox("Task to add:", "Add")
  If Item <> "" Then
     P = Me.CboTodo.FindString(Item) 'is item already in box?
     If P = -1 Then 'add if not there already
        P = Me.CboTodo.FindString(Item)
     End If
     Me.CboTodo.SelectedIndex = P 'display added item
  End If
End Sub 'AddItem

NEXT: Save