Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Use of Shortcut keys in VB (VB6)

    In VB6 are the shortcut keys F1 to F12 limited to the menu items or can they be captured from a form?

    I have a pop-up form with a search button on it, which I was hoping to set a shortcut of F8 to as that would match our Access product. The Function keys don't get picked up on the keypress/keydown events, and the only way I seem to be able to access them is to add a menu to the form with a subitem and add the F8 shortcut to that.
    Is this the only way to use the function keys in VB6?

    Any help would be much appreciated.
    Regards,

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Use of Shortcut keys in VB (VB6)

    You can use the On KeyDown event. If you set the KeyPreview property of the form to True, all keyboard events will be passed to the form first. Example:

    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
    Case vbKeyF1
    ...
    Case vbKeyF2
    ...
    Case Else
    ...
    End Select
    End Sub

    If you want to stop further processing of the key, set KeyCode to 0. See KeyDown, KeyUp Events.

  3. #3
    4 Star Lounger
    Join Date
    Feb 2001
    Location
    Gillingham, Kent, England
    Posts
    511
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Use of Shortcut keys in VB (VB6)

    Thanks Hans, thats sorted it perfectly.
    I didn't know about the KeyPreview property!

    Regards,

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •