|
-
Jun 20th, 2005, 11:48 PM
#1
Thread Starter
Hyperactive Member
Using ESC Key............
hi
how can i use ESC key to unload form in a form with 10 or more textboxes and other controls too. the focus will be in textbox when the form get loaded
saj
-
Jun 21st, 2005, 12:00 AM
#2
Re: Using ESC Key............
To unload a Form with a command button in it (perhaps a Close/Exit button with an Unload Me in it) you could set its Cancel property to True so that when you press Esc it will be triggerred (it will execute the code bin its click event).
-
Jun 21st, 2005, 12:01 AM
#3
Re: Using ESC Key............
if you have a command button to close the form, set it,s cancel property to true
pete
-
Jun 21st, 2005, 12:01 AM
#4
Fanatic Member
Re: Using ESC Key............
You should be able to use the keydown event..not sure if the keycode here is correct but this will give you the idea anyway
VB Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = VBEsc then
unload me
End If
End Sub
Edit---
Ok, I'm slow AND behind the curve!
-
Jun 21st, 2005, 12:18 AM
#5
Re: Using ESC Key............
anotherVBnewbie's idea would work too but you have to set the Form's KeyPreview = True.... I forgot the constant for the ESC...
VB Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 27 then
unload me
End If
End Sub
-
Jun 21st, 2005, 01:46 AM
#6
Thread Starter
Hyperactive Member
Re: Using ESC Key............
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
|