Results 1 to 5 of 5

Thread: Keydown problem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    What's wrong with this code ??
    When the user presses shift and "+" or shift and "-" then I want something to happen.

    Code:
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    
    If KeyCode = vbKeyF11 Then Call sscmdMenu_Click
    If (Shift And vbShiftMask) > 0 Then
        If KeyCode = vbKeyAdd Then
            'Do something
        End If
        If KeyCode = vbKeySubtract Then
            'Do something
        End If
    End If
    
    End Sub

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Post

    I usually use the built in constants like you do, but in this case I don't know what they are. However if you change vbkeyadd to 187 and vbKeySubtract to 109 it will work.

    ------------------
    Marty

  3. #3
    New Member
    Join Date
    Jun 1999
    Posts
    6

    Post

    Easy way to find the key constant is to add this to your code.

    debug.print (insert constant here)

    This will print the constant value to the Immediate window.

    ------------------
    Micheal Blackthorne

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 1999
    Posts
    309

    Post

    MartinLiss, where did you find the dec's 187 and 109 ??
    I want to know if there is a list in msdn or something ...

    Cause 109 does'not seem to work...

    B.T.W. that was pretty usefull information there, Blackthorne.. Anyways I could to the oposite of that (give a dec and get the constant) ??



    [This message has been edited by Inhumanoid (edited 11-30-1999).]

  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,427

    Post

    I did what Blackthorne suggested and put Debug.Print KeyCode in the KeyDown event. 109 is what you get when you press the "-" key on the numeric key-pad. I thought that is the minus key you meant as opposed to the one on the main keyboard, because you said you wanted to trap Shift plus "-". On the main keyboard that's "_", not "-".

    ------------------
    Marty

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