Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using KeyPress Event 1

Status
Not open for further replies.

Rob7

Programmer
Dec 12, 2001
152
0
0
US
This should be a pretty simple thing to do but I am having a problem getting a KeyPress event to work. What I want to do is have my code fire when the user presses the F10 button. I can get the code to work with other keys, just not the F10.

Thanks
 
F10 doesn't generate a keyAscii code. Use the KeyDown Event:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF10 Then
' ... do something
KeyCode = 0 ' set to empty keypress
End If
End Sub


Mark
 
The ascii code for F10 is 121 ...

so

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 121 Then
MsgBox ("Begin Event!")
' call letsgo!
End If
' MsgBox KeyCode
End Sub

Similarly it would work with object_KeyDown I imagine. .

see:

for the full skinny.

--- David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top