Results 1 to 10 of 10

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

  1. #1

    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

    Use this app to get the Ascii values of the keys on the keyboard.
    Attached Files Attached Files
    Last edited by Nightwalker83; Apr 29th, 2011 at 03:39 AM. Reason: Reuploading source code!
    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

  2. #2
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Didn't try the .exe tho (viruses)

    But this is also an option:
    VB Code:
    1. 'Place a ListBox on a Form.
    2. 'Will display All Ascii Characters
    3. Private Sub Form_Load()
    4. Dim i As Integer
    5.  
    6.     For i = 0 To 255
    7.         List1.AddItem "Decimal: " & i & " = Char: " & Chr(i)
    8.     Next
    9. End Sub

  3. #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

  4. #4
    New Member
    Join Date
    Mar 2010
    Posts
    1

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

    helpful ty

  5. #5
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

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

    I found that you are using End in most of your projects. That's not a good practice. See this FAQ for more details: Why is using the 'End' statement (or VB's "stop" button) a bad idea? ...

    Good luck ...

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  6. #6

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

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

    Quote Originally Posted by akhileshbc View Post
    I found that you are using End in most of your projects. That's not a good practice.

    Good luck ...
    Yeah, I know! However since, it has been years since I originally wrote the code I hadn't double checked to make sure I used unload me instead of end.
    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

  7. #7
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

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

    Quote Originally Posted by Nightwalker83 View Post
    Yeah, I know! However since, it has been years since I originally wrote the code I hadn't double checked to make sure I used unload me instead of end.
    Why don't you edit your post(the above one) and include it now...???

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  8. #8

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

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

    Quote Originally Posted by akhileshbc View Post
    Why don't you edit your post(the above one) and include it now...???
    I have amended post #3 and put unload me in Command1_Click but I has left the end in there but commented it out. There is an explanation of why I did this in post #3.
    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

  9. #9
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

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

    Quote Originally Posted by Nightwalker83 View Post
    I have amended post #3 and put unload me in Command1_Click but I has left the end in there but commented it out. There is an explanation of why I did this in post #3.
    ....
    Quote Originally Posted by Nightwalker83 View Post
    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
    Then I think, this code block itself is not needed:
    Code:
    Private Sub Command1_Click()
    Unload Me
    'End
    End Sub
    ( I am just expressing my thoughts )...

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  10. #10

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

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

    Quote Originally Posted by akhileshbc View Post
    ....


    Then I think, this code block itself is not needed:
    Code:
    Private Sub Command1_Click()
    Unload Me
    'End
    End Sub
    ( I am just expressing my thoughts )...
    Ah well, the users can decided whether they want to keep it in there or not. Maybe it will come in handy for something else I'm not forcing them to use any of the code.
    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