[RESOLVED] Numeric Textbox with "backspace"
Im using
Code:
Private Sub NumericKeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim allowedChars As String = "0123456789"
If allowedChars.IndexOf(e.KeyChar) = -1 Then
e.Handled = True
End If
End Sub
and it wont let me use backspace. How would I make it so I can use backspace?
Re: Numeric Textbox with "backspace"
Take a look at the list of characters you've allowed ... and be aware that the backspace is simply another character.
Re: Numeric Textbox with "backspace"
Quote:
Originally Posted by
OldProgrammer
Take a look at the list of characters you've allowed ... and be aware that the backspace is simply another character.
What would be the Backspace though?
Re: Numeric Textbox with "backspace"
Forget testing against an array:
vb.net Code:
e.Handled = Not Char.IsDigit(e.KeyChar) AndAlso Not Char.IsControl(e.KeyChar)
IsControl accounts for baskspace, delete and others.