Private Sub Form_Load()
' Create the menu items.
CreateMenuItem "Command &1"
CreateMenuItem "Command &2"
CreateMenuItem "Command &3"
End Sub
' Create a new menu item in the Commands menu.
Private Sub CreateMenuItem(ByVal menu_caption As String)
Static menu_num As Integer
' Create the menu entry.
If mnuCommands.Enabled Then
' Load a new entry.
menu_num = menu_num + 1
Load mnuCommandsSub(menu_num)
Else
' This is the first menu item. Use entry 0.
mnuCommands.Enabled = True
menu_num = 0
End If
mnuCommandsSub(menu_num).Caption = menu_caption
End Sub
Private Sub mnuCommandsSub_Click(Index As Integer)
Select Case mnuCommandsSub(Index).Caption
Case "Command &1"
MsgBox "Execute command 1"
Case "Command &2"
MsgBox "Execute command 2"
Case "Command &3"
MsgBox "Execute command 3"
End Select
End Sub
|