Keyascii

kwA
03-27-2004, 10:37 PM
Where can I find different keyascii values for the F keys?
Or how can I do this:
Either using ascii or another replacement for an F key?

Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = bah Then
Call bloop
End If
End Sub

webbone
03-27-2004, 10:46 PM
By "F Keys" do you mean the Function keys? If so you cannot detect those in the KeyPress event. You can use the following code to demonstrate this to yourself:


Private Sub Text1_KeyPress(KeyAscii As Integer)
MsgBox KeyAscii
End Sub


You CAN capture the Function keys, navigation keys, etc. using the KeyDown and KeyUp events.

VB comes with a set of predefined constants for the function keys - vbKeyF1 can be used to detect this key:


Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyF1 Then
MsgBox "The F1 key was pressed"
End If
End Sub


EDIT: I forgot to add - you can get the various keycode constants from the Object Browser in the VB IDE. Right-mouse in the code window and select KeyCode Constants in the Class pane.

kwA
03-27-2004, 10:54 PM
tyvm :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum