|
-
Oct 3rd, 2000, 05:09 AM
#1
Thread Starter
Member
how can i enable the escape key function to close a form?
-
Oct 3rd, 2000, 05:28 AM
#2
Lively Member
If you have a Cancel button that closes the form, just set that buttons Cancel property to true. The Escape will then trigger the Cancel-buttons clickevent.
-
Oct 3rd, 2000, 05:32 AM
#3
Hyperactive Member
if not u can use this code in ur form,
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'27 is the keycode for the escape key
If KeyCode = 27 Then End
End Sub
-
Oct 3rd, 2000, 05:35 AM
#4
Lively Member
But will that trigger if you are in a control on the form?
-
Oct 3rd, 2000, 06:15 AM
#5
Originally posted by Thomas Halsvik
But will that trigger if you are in a control on the form?
Set the form's KeyPreview property to True and it will work, even if you have a control selected, it will still work.
-
Oct 3rd, 2000, 07:34 AM
#6
Frenzied Member
I can't say it too often, don't use end to stop your program, it's a rude way to quit your program.
Use Unload Me to quit your program.
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'VBKeyEscape is easier to follow then 27
If KeyCode = vbKeyEscape Then
Unload Me
End If
End Sub
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|