LennyGray
asked on
converting e.KeyCode to the keyboard value in a message
How do I convert e.KeyCode to the actual keyboard key name like "F1" where the line of code would look like:
MsgBox(ConvertThis(e.KeyCo de) & " is an invalid key. Please choose F2 through F9 only.", CType((MsgBoxStyle.Informa tion + MsgBoxStyle.OkOnly), MsgBoxStyle), "Lenny's Message")
Where ConvertThis is a function that will convert e.KeyCode to the function key or keyboard character that the user depressed.
The messagebox would have this message, if the F1 key was depressed by the user:
F1 is an invalid key. Please choose F2 through F9 only.
Thanks!
Lenny
MsgBox(ConvertThis(e.KeyCo
Where ConvertThis is a function that will convert e.KeyCode to the function key or keyboard character that the user depressed.
The messagebox would have this message, if the F1 key was depressed by the user:
F1 is an invalid key. Please choose F2 through F9 only.
Thanks!
Lenny
if e.KeyCode = keys.F10 etc.
ASKER
I already knew that because I have case statements for all of the keys that I want to react to from F2 to F9.
Case Keys.F1, Keys.F10, Keys.F11, Keys.F12
MsgBox(ChrW(e.KeyCode) & " is an invalid key. Please choose F2 through F9 only.", CType((MsgBoxStyle.Informa
e.Handled = True
End Select
ChrW gives me a "p" when I hit F1 not "F1"
Thanks, but I wanted something more automatic. Case Else is no good because it picks up all keys depressed.
Maybe this will give you an idea of what I am trying to do.
Lenny
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect !!!
Thanks a lot. I have 38 years of database programming experience but I am just learning dot net. Be prepared to earn a lot of points from me!
Thanks a lot. I have 38 years of database programming experience but I am just learning dot net. Be prepared to earn a lot of points from me!