|
-
Mar 30th, 2006, 08:02 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Hi
I have a VB6 form containing 3 command buttons.I want to create a shortcut to each control.For example when they press F1, command1 is executed,when they press F2 command2 is executed, when they press ESC command Exit is executed.
-
Mar 30th, 2006, 08:05 AM
#2
Re: Hi
Hi is not a proper title.
Set the keypreview property of your form to true and write this
VB Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF1
Call Command1_Click
Case vbKeyF2
Call Command2_Click
Case vbKeyF3
Call Command3_Click
End Select
End Sub
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Mar 30th, 2006, 01:18 PM
#3
Re: Hi
 Originally Posted by engnouna
when they press ESC command Exit is executed.
You don't need code for this. Place a standard command button on the form and enter 'Cancel' as its Caption property, and put Unload Me in its click event. Next, set the control's Cancel property to True. When Cancel Property is set to True VB executes the button's Click() event whenever you press the [Esc] key (as well as when you click it).
BTW:
 Originally Posted by Shuja Ali
Hi is not a proper title.
This is correct. Something like "Relate Function Keys To Command Buttons" would be more accurate.
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
|