Thread: [Solved] KeyCode Conversion
View Single Post
 
Old 06-03-2012, 06:50 PM
joatmon joatmon is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: May 2012
Posts: 14
joatmon is on a distinguished road
Default KeyCode Conversion

I have a textbox on a userform that I am trying to work with the KeyDown event. I'm trying to capture the user's input using the KeyCode. I thought that KeyCode would just return ASCII values, but this is proving not to be the case. Take this very simple code for illustration:

Code:
Private Sub txtAnswer_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    MsgBox (KeyCode)
End Sub
If I enter the number "3" on the keyboard, what comes out is the number 99. I was expecting the number 51 to appear since that is the ASCII value for the character "3".

Can anybody explain this behavior to me? It's probably pretty simple, but I don't know how to translate this.

Thank you!
Reply With Quote