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
Printable View
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
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).
if you have a command button to close the form, set it,s cancel property to true
pete
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! :blush:
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
thnk u all,