KeyAscii Chart(resolved)-VBForums
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
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    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
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

  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
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,088

    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!
    • Star Wars Gangsta Rap • Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
    System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 300 GB HDs, 2 GBs DDR2 667 MHz RAM, 2 Viewsonic 24" LCDs, Windows 7 SP-1/Windows 8.1, Office 2010, VS 2013

  6. #6
    Super Moderator Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    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.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section.

    Creating A Wizard In VB.NET
    Paging A Recordset
    What is wrong with using On Error Resume Next
    Good Article: Language Enhancements In Visual Basic 2010
    Upgrading VB6 Code To VB.NET
    Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked

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

    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,363

    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
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    32,860

    Re: KeyAscii Chart

    I don't think there are vbKeyEnter or vbKeyBackspace, but there are vbKeyReturn and vbKeyDelete.

  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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.