Esc key is normally not used as a shortcut key as for a menu item. However, if you want to use it for this purpose, you need to perform these steps.
Place a command button on your form and set its properties as under.
Name = "cmdCancel"
Cancel = True
Left = -1000
TabStop = False
Place the following code in your form.
___
Private Sub cmdCancel_Click()
myMenuItem_Click
End Sub
Private Sub myMenuItem_Click()
MsgBox "myMenuItem_Click"
End Sub
___
And to display "Esc" as a shortcut key in front of the caption of your menu item, insert the following line of code in Form_OnLoad event.
___
myMenuItem.Caption = myMenuItem.Caption & vbTab & "Esc"
___
Note that myMenuItem is the name of the menu item you are interested in. Run the program and test it.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.