Results 1 to 10 of 10

Thread: Function Keys ex: F8, F4, etc & Ansi Code

  1. #1

    Thread Starter
    Hyperactive Member Sal's Avatar
    Join Date
    Mar 2000
    Posts
    262

    Wink

    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.



    So start talkin' err typing!

    Thanks,
    Sal
    VB-6 Professional Edition (Sp3)
    www.safemall.cc
    [email protected]

    Climb & Maintain FL410,
    Cleared Direct Rainr

  2. #2
    Guest
    They can be represented by Constants.

    vbKeyF1
    vbKeyF2
    vbKeyF3
    vbKeyF4

    etc.



  3. #3

    Thread Starter
    Hyperactive Member Sal's Avatar
    Join Date
    Mar 2000
    Posts
    262

    Cool

    How you doin' megatron?



    Thanks for the quick response. Just found that same answer as a reference in one of my many books.

    Thanks again,
    Sal
    VB-6 Professional Edition (Sp3)
    www.safemall.cc
    [email protected]

    Climb & Maintain FL410,
    Cleared Direct Rainr

  4. #4
    Guest
    For a whole list of them, refer to Keycode Constants in your Help File.

  5. #5

    Thread Starter
    Hyperactive Member Sal's Avatar
    Join Date
    Mar 2000
    Posts
    262
    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
    VB-6 Professional Edition (Sp3)
    www.safemall.cc
    [email protected]

    Climb & Maintain FL410,
    Cleared Direct Rainr

  6. #6
    Guest
    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.

  7. #7

    Thread Starter
    Hyperactive Member Sal's Avatar
    Join Date
    Mar 2000
    Posts
    262
    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
    VB-6 Professional Edition (Sp3)
    www.safemall.cc
    [email protected]

    Climb & Maintain FL410,
    Cleared Direct Rainr

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9

    Thread Starter
    Hyperactive Member Sal's Avatar
    Join Date
    Mar 2000
    Posts
    262
    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
    VB-6 Professional Edition (Sp3)
    www.safemall.cc
    [email protected]

    Climb & Maintain FL410,
    Cleared Direct Rainr

  10. #10

    Thread Starter
    Hyperactive Member Sal's Avatar
    Join Date
    Mar 2000
    Posts
    262
    Great!




    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
    VB-6 Professional Edition (Sp3)
    www.safemall.cc
    [email protected]

    Climb & Maintain FL410,
    Cleared Direct Rainr

Posting Permissions

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



Click Here to Expand Forum to Full Width