I was just wondering... in VB6, there is a way to handle keystrokes, and it used the vbKey constants. How do you do this kind of thing in VB.Net?
Printable View
I was just wondering... in VB6, there is a way to handle keystrokes, and it used the vbKey constants. How do you do this kind of thing in VB.Net?
In the keypress event code for a given control, you'll have something like:
Code:Select Case e.KeyChar
Case "+", Microsoft.VisualBasic.ChrW(Keys.Enter)
'Some logic
e.Handled = True
Case "-"
'Some other logic
e.Handled = True
End Select
Yay, it worked! Thanks for the help!
One thing though; it didn't work for the main form's KeyPress event... why is that?
Might be because the keypress was handled by the control with focus rather than the main form itself.Quote:
Originally posted by 347Studboy
One thing though; it didn't work for the main form's KeyPress event... why is that?