Results 1 to 13 of 13

Thread: KeyAscii Chart(resolved)

  1. #1

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Resolved KeyAscii Chart(resolved)

    Hello,

    Does anyone have a chart for the KeyAscii values for each key on the keyboard? It'd be greatly appreciated if you sent me it
    Last edited by paralinx; Oct 20th, 2005 at 01:15 PM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: KeyAscii Chart

    Is this what you mean?
    Code:
    If you type "vbKey" and then press Ctrl+Space, you get a dropdown list of all the constants.
    
    vbKeyLButton    Left Mouse Button
    vbKeyRButton    Right Mouse Button
    vnKeyCancel     Cancel Key
    vbKeyMButton    Middle Mouse button
    vbKeyBack       Back Space Key
    vbKeyTab        Tab Key
    vbKeyClear      Clear Key
    vbKeyReturn     Enter Key
    vbKeyShift      Shift Key
    vbKeyControl    Ctrl Key
    vbKeyMenu       Menu Key
    vbKeyPause      Pause Key
    vbKeyCapital    Caps Lock Key
    vbKeyEscape     Escape Key
    vbKeySpace      Spacebar Key
    vbKeyPageUp     Page Up Key
    vbKeyPageDown   Page Down Key
    vbKeyEnd        End Key
    vbKeyHome       Home Key
    vbKeyLeft       Left Arrow Key
    vbKeyUp         Up Arrow Key
    vbKeyRight      Right Arrow Key
    vbKeyDown       Down Arrow Key
    vbKeySelect     Select Key
    vbKeyPrint      Print Screen Key
    vbKeyExecute    Execute Key
    vbKeySnapshot   Snapshot Key
    vbKeyInsert     Insert Key
    vbKeyDelete     Delete Key
    vbKeyHelp       Help Key
    vbKeyNumlock    Delete Key
    
    vbKeyA through vbKeyZ are the key code constants for the alphabet
    vbKey0 through vbKey9 are the key code constants for numbers
    vbKeyF1 through vbKeyF16 are the key code constants for the function keys
    vbKeyNumpad0 through vbKeyNumpad9 are the key code constants for the numeric key pad
    
    Math signs are:
    vbKeyMultiply      -  Multiplication Sign (*)
    vbKeyAdd             - Addition Sign (+)
    vbKeySubtract     - Minus Sign (-)
    vbKeyDecimal    - Decimal Point (.)
    vbKeyDivide        - Division sign (/)
    vbKeySeparator  - Enter (keypad) sign

  3. #3

  4. #4

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: KeyAscii Chart

    yes exactly thank you. How would I work these functions into my form. I tried something like:
    VB Code:
    1. Private Sub Form_KeyPress(KeyAscii as Integer)
    2.      Select Case KeyAscii
    3.            Case vbKeyReturn
    4.                   msgbox "Return"
    5.      End Select
    6. End Sub
    But that does not work.

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    Re: KeyAscii Chart

    You can also display them as they are on your system.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     Dim i As Integer
    5.     For i = 0 To 255
    6.         Debug.Print "ASCII "; i & " : " & Chr(i)
    7.     Next
    8. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: KeyAscii Chart

    Quote Originally Posted by paralinx
    yes exactly thank you. How would I work these functions into my form. I tried something like:
    VB Code:
    1. Private Sub Form_KeyPress(KeyAscii as Integer)
    2.      Select Case KeyAscii
    3.            Case vbKeyReturn
    4.                   msgbox "Return"
    5.      End Select
    6. End Sub
    But that does not work.
    You would be better off using them with a control like a textbox. KeyPress will only fire if the control has focus.

  7. #7
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: KeyAscii Chart

    what goes wrong with your code?
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  8. #8

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: KeyAscii Chart

    Oh, well what would I use for the form. Form_KeyDown? Because I'm trying to make a command button move with my arrow keys

  9. #9
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: KeyAscii Chart

    btw I dont think the form will capture a return..
    try your code in a textbox keypress
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  10. #10

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: KeyAscii Chart

    try this code in a blank project and tell me if it works for you:

    Code:
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
        On Error Resume Next
        Select Case KeyCode
            Case vbKeyEnter
                MsgBox "Enter Key Pressed"
            Case vbKeyBackSpace
                MsgBox "Delete Key Pressed"
            Case vbKeyA
                MsgBox "A Key Pressed"
        End Select
    End Sub

  11. #11

  12. #12

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: KeyAscii Chart

    Yeah I fixed that I know why the above code (with the correct KeyAscii assignments) doesn't work. I have a command button and the focus is set on the command button and not the form. Is there a way to set focus to the form..?

  13. #13

    Thread Starter
    Fanatic Member paralinx's Avatar
    Join Date
    Jun 2005
    Location
    Michigan
    Posts
    987

    Re: KeyAscii Chart

    nevermind got it to work

    thanks for ya'lls help

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