JumpyNET
Centurion
- Joined
- Apr 4, 2005
- Messages
- 196
What is the shortest way to check if a pressed key is alphanumeric in a KeyDown event?
PS: I'm using VB2005 Express.
PS: I'm using VB2005 Express.
I've just tended to check with Char.IsLetterOrDigit
Private Sub MyControl_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Lista.KeyDown
Dim PressedChar As Char = Chr(e.KeyCode)
If Char.IsLetterOrDigit(PressedChar) Then
MsgBox("You pressed: " & PressedChar)
End If
End Sub
I would use the KeyPress event rather than the KeyUp / Down as you get the actual character with the press event.