Function keys are a boon for assigning shortcuts. They have more advantage than the regular Alt +
Function keys can be assigned to command buttons using simple tricks as explained below. For that we need to instuct the VB to handle them in t
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirxYx_-0w4l_M8ucU18vhn478hpPd5dcTwFO28Sb-EfumJpUu44lyiD5qFoGCnTJZaYNQmNmp5HsD_PdfMxs3D9Fbk9p2iAqrRJ-5vTfQTAp9XeDNK_yU-tBAVoNxbh1CqOCtE/s400/KeyPreview.gif)
Then you can have the necessary shortcut keys on the form
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_wvtbpqTGgFsIecP5McmGofDO305-M2iXK0_4cC5p7uW29QnZKQl2okUS0fsWCPYS9gTuCbAdAjs9KRkwNqaIA9uhSANZv0la1GEE4eMgCanCnS-XvtP4fIoc15z9nOX_zhOX/s400/KeyPreview2.gif)
In the Form_KeyDown event redirect to necessary functions/procs based on the key
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF2
Call Proc_Fund_Transfer
Case vbKeyF3
Call Proc_Credit_Card
End Select
End Sub
I wanted to use function keys to move through a recordset displayed in a form. ANd the keydown event works with the keypreview property of the form set to true. HOWEVER, I used F10 and F9 as movenext and moveprevious
ReplyDeleteand when I look at the keycodes being generated , on of the funciton keys only regristers on EVERY-OTHER keydown event, yet the KEYUP event fires correctly. DOes anyone know why this would be or how to fix it.
Thanks!
I need to do this but in visual studio 2008, anyone can help me
ReplyDeleteCheck if the following helps you:
ReplyDeletehttp://dotnetdud.blogspot.com/2011/05/how-to-use-function-keys-in-vbnet.html
This one doesn't work for me. I've tried to use KeyDown event of my form. But the Sub is never called.
ReplyDeleteDoes work OK for me.
ReplyDeletethanks >>> much thanks
ReplyDelete