'第一种事件: Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case Is = "Exit" Unload me End Select End Sub '第二种事件: Private Sub Command1_Click() Unload me End Sub
2
4
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyE And Shift = 2 Then Dim Button As MSComctlLib.Button Toolbar1.Tag = "Exit" Call Toolbar1_ButtonClick(Button) End If End Sub Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) If Toolbar1.Tag <> "" Then GoTo Line Select Case Button.Key Case Is = "Exit" MsgBox "Exit" End Select Line: Select Case Toolbar1.Tag Case Is = "Exit" MsgBox "Exit" End Select End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyE And Shift = 2 Then Dim Button As MSComctlLib.Button Toolbar1.Tag = "Exit" Call Toolbar1_ButtonClick(Button) End If End Sub Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) If Toolbar1.Tag <> "" Then GoTo Line Else Select Case Button.Key Case Is = "exit" MsgBox "Exit" End Select End If Line: Select Case Toolbar1.Tag Case Is = "Exit" MsgBox "Exit" Toolbar1.Tag = "" End Select End Sub