[RESOLVED] TextBox Question
My question is I have a masked text box for a phone number to be entered. I want the user to be only able to enter numbers and the backspace key. I don't want the user to be able to use the space button. Here is the code I have:
Code:
Private Sub xPhoneNumberTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) _
Handles xPhoneNumberTextBox.KeyPress
If e.KeyChar = " "c Then
e.Handled = True
ElseIf e.KeyChar < "0" OrElse e.KeyChar > "9" AndAlso e.KeyChar <> ControlChars.Back Then
e.Handled = True
End If
End Sub
My problem is spaces can still be entered into the text box. What am I doing wrong?