Monday, September 20, 2010

Function Key "F10" in Visual Basic


F10 Key once detected on Form using KeyPreview property, will never trigger the same event unless user press F10 again. This is an amazing problem. Let say, you want to detect keys on Form_KeyUp or Form_KeyDown, and user pressed F10, than no other key will trigger this event until user re-press F10. The reason behind this behavior is that key [F10] trigger the "System Menu" on form, either you have menu or not, it does not matter. Therefore, always set Keycode to ZERO, before exiting from Form_KeyUp or Form_KeyDown events. See Below;

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
rem
rem blah, blah...
rem
KeyCode = 0
Exit Sub

Have a nice sip of VB6.

No comments:

Post a Comment