ASCII


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: ASCII

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    ASCII

    [Originally posted by Chris]

    What are the ASCII values for the arrow keys?

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:ASCII

    [Originally posted by Greg DeBacker]

    This info is in the help file but you can also get the values by using the KeyUp, KeyDown, or KeyPress events in a VB TextBox (or other controls with these events). Put a MsgBox statement in the event, make sure the contorl has the focus, and then press the desired key to get its code.

    Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
    MsgBox KeyCode
    End Sub


    You can also use the VB KeyCode constants like...

    vbKeyLButton 1 Left mouse button
    vbKeyRButton 2 Right mouse button
    vbKeyCancel 3 CANCEL key
    vbKeyMButton 4 Middle mouse button
    vbKeyBack 8 BACKSPACE key
    vbKeyTab 9 TAB key
    vbKeyClear 12 CLEAR key
    vbKeyReturn 13 ENTER key
    vbKeyShift 16 SHIFT key
    vbKeyControl 17 CTRL key
    vbKeyMenu 18 MENU key
    vbKeyPause 19 PAUSE key
    vbKeyCapital 20 CAPS LOCK key
    vbKeyEscape 27 ESC key
    vbKeySpace 32 SPACEBAR key
    vbKeyPageUp 33 PAGE UP key
    vbKeyPageDown 34 PAGE DOWN key
    vbKeyEnd 35 END key
    vbKeyHome 36 HOME key
    vbKeyLeft 37 LEFT ARROW key
    vbKeyUp 38 UP ARROW key
    vbKeyRight 39 RIGHT ARROW key
    vbKeyDown 40 DOWN ARROW key
    vbKeySelect 41 SELECT key
    vbKeyPrint 42 PRINT SCREEN key
    vbKeyExecute 43 EXECUTE key
    vbKeySnapshot 44 SNAPSHOT key
    vbKeyInsert 45 INS key
    vbKeyDelete 46 DEL key
    vbKeyHelp 47 HELP key
    vbKeyNumlock 144 NUM LOCK key

    Grex

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:ASCII

    [Originally posted by Rod]

    Add a TextBox using the default name Text1 a lable and two command buttons to a form.

    '*** CREDIT ***
    '
    'This snippet was found in news group:
    'microsoft.public.vb.general.discussion
    'in response to 'Right click-key?'
    'Reply to above question and code below was
    'answered by Rick Rothstein

    Option Explicit

    Private Sub Command1_Click()
    Unload Me
    End Sub

    Private Sub Command2_Click()
    Text1.Text = ""
    Label1.Caption = "<--- Hit any key and view key code"
    Text1.SetFocus
    End Sub

    Private Sub Form_Load()
    Text1.TabIndex = 0
    End Sub

    Private Sub Text1_KeyPress(KeyAscii As Integer)
    Dim sAscii As String

    sAscii = KeyAscii
    Label1.Caption = sAscii & " ASCII Key Code"
    Text1.Text = ""
    End Sub

    HTH

  4. #4
    Join Date
    Aug 2004
    Posts
    43,023

    Re:ASCII

    [Originally posted by Rod]

    Add a TextBox using the default name Text1 a lable and two command buttons to a form.

    '*** CREDIT ***
    '
    'This snippet was found in news group:
    'microsoft.public.vb.general.discussion
    'in response to 'Right click-key?'
    'Reply to above question and code below was
    'answered by Rick Rothstein

    Option Explicit

    Private Sub Command1_Click()
    Unload Me
    End Sub

    Private Sub Command2_Click()
    Text1.Text = ""
    Label1.Caption = "<--- Hit any key and view key code"
    Text1.SetFocus
    End Sub

    Private Sub Form_Load()
    Text1.TabIndex = 0
    End Sub

    Private Sub Text1_KeyPress(KeyAscii As Integer)
    Dim sAscii As String

    sAscii = KeyAscii
    Label1.Caption = sAscii & " ASCII Key Code"
    Text1.Text = ""
    End Sub

    HTH

  5. #5
    Join Date
    Aug 2004
    Posts
    43,023

    Re:ASCII

    [Originally posted by David Chapman]

    Arrow keys do NOT have ASCII values, nor do keys such as Ctrl, Alt, Shift.
    For a table of ASCII characters see http://www.ecs.umass.edu/ece/hill/engin191.dir/ascii.html
    Arrow keys do however have Key codes assigned to them in VB as Grex explained.

    Dave

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center