fattyfatpants
Programmer
I am wondering how I might go about ignoring certain keystrokes but not others.
Example: I want a user to only enter a 10 digit telephone number without dashes and other non numeric info
I tried coding in the KeyDown event to look for any non numeric info and ignore it
Example: I want a user to only enter a 10 digit telephone number without dashes and other non numeric info
I tried coding in the KeyDown event to look for any non numeric info and ignore it
Code:
Private Sub txtPhone_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtPhone.KeyDown
Select Case e.KeyCode
Case Keys.D0 To Keys.D9, Keys.Delete, Keys.Back
'all is good
Case Else
'ignore the key like it was never pressed
End Select
End Sub