Results 1 to 10 of 10

Thread: Get both the Keycode and Ascii values of keys pressed

Threaded View

  1. #3

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Get both the Keycode and Ascii values of keys pressed

    Hi,

    This code will output (to a text file) the ascii value of the key on the keyboard which was pressed. This code was written in Visual Basic 6.0.

    vb Code:
    1. Private Sub Command1_Click()
    2. Unload Me
    3. 'End
    4. End Sub
    5.  
    6. Private Sub Text1_Change()
    7. Open App.Path & "\keyboard.txt" For Append As #1
    8. Print #1, Label2.Caption & " " & Text1.Text
    9. Close #1
    10. End Sub
    11.  
    12. Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
    13. Label2.Caption = Chr(KeyCode)
    14. Text1.Text = KeyCode
    15. End Sub
    16.  
    17.  
    18. Private Sub Text1_KeyPress(KeyAscii As Integer)
    19. Label2.Caption = Chr(KeyAscii)
    20.  MsgBox "Asciikey: " & KeyAscii
    21. End Sub

    Edit:

    The commented out parts were apart of the original code but are not needed to preform the task suggested in the thread title.

    Nightwalker
    Last edited by Nightwalker83; Mar 15th, 2010 at 08:28 PM. Reason: Fixing spelling
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

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