-
Hi All,
Just printed the character set 0-127 and 128-255 from the VB Help file. I was looking for the numerical values which represent function keys.
I know one of you who is reading this now has the answer.
:p
So start talkin' err typing!
Thanks,
Sal
-
They can be represented by Constants.
vbKeyF1
vbKeyF2
vbKeyF3
vbKeyF4
etc.
-
How you doin' megatron?
:cool:
Thanks for the quick response. Just found that same answer as a reference in one of my many books.
Thanks again,
Sal
-
For a whole list of them, refer to Keycode Constants in your Help File.
-
Megatron,
I'm trying to setup a function key that will allow the user to call a sub (ex - Private Sub Command1_Click() ). I wonder if any of the other controls on the form would conflict with the keyup event?????
Ideas?
Thanks again,
Sal
-
If you have a PictureBox, TextBox, RichTextBox (and probably some others) it might cause conflicts because they have the focus when they the Form starts up.
-
Yea...
Still researching this. I wonder if there is a command button or maybe an OCX which has the keycode property or shortcut key property. That would be perfect. I'll let you know what I find out.
Sal
-
Be aware of the menu shortcuts also, even if you have keypreview set and use textbox to paste, you will fire the menu code instead. Otherways, keypreview is the best way to dismiss this problem
-
You know, this should be simple. There are games that allow you to press a function key while all kinds of junk is going on. You could for example press F4 to bring the flaps full down while in a left turn, and it works irregardless of what has focus.
Kedaman I think is on to something. I am studying the vb-helpfile as we speak.
Will report the solution here, along with the code.
Thanks,
Sal
-
Great!
:p
Got the answer. It was in the MSD Library. Here it is...
KeyPreview Property Example
This example creates a form keyboard handler in the KeyDown event. Each of the first four function keys displays a different message. To try this example, paste the code into the Declarations section of a form, and then press F5. Once the program is running, press any one of the first four (F1 – F4) function keys.
Code:
Private Sub Form_Load ()
KeyPreview = True
End Sub
Private Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF1: MsgBox "F1 is your friend."
Case vbKeyF2: MsgBox "F2 could copy text."
Case vbKeyF3: MsgBox "F3 could paste text."
Case vbKeyF4: MsgBox "F4 could format text."
End Select
End Sub
Your leads were good.
Thanks,
Sal