-
I noticed in the menu editor that it doesn't allow for esc, page up, or page down to be a short cut?? Is there a way around this?? I know i can use the KeyPress event, but I'm not sure where to put the code?? i just want to enable the user to push escape anytime during the program, and for the program to terminate.. thanks you
-
Set the Form's KeyPreview Property to True
Then add this code:
Code:
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyEscape Then
'code to termanate(unload all forms)
End If
End Sub
-
how about using vbKeyEsc that works... sometimes... try it at least...
give it a shot
-
whooops!
I guess gwdash already answered... thnx
-
u might wanna replace:
'code to termanate(unload all forms)
with:
End
-
MoMad:
Using End on this board is sacreligious!
-
That's why i said it the way i did, i don't want to start a Holy War!!!!!
-
END should never be used by itself.
Use this code to end your program:
Code:
Public Sub UnloadAllForms()
Dim Form As Form
For Each Form In Forms
Unload Form
Set Form = Nothing
Next Form
End Sub
Usage
UnloadAllForms
And in your menus, if you want to emulate a shortcut key, like that space between the words and a shortcut:
Code:
mnuExit.Caption = "&Exit" & Chr$(9) & "Esc"
-
..
Thanks everyone for the responses, it's been while since i have programmed in vb, i understand everything about what mathew gates said, but what does the set form = nothing do?? thanks
-
It will free up any resources that your form is using from memory .