0

Hi Guys!

I coded my textbox to be only type in numeric numbers. But the backspace doesn't work when I run the program anymore, Can't delete what has typed in the textbox.

Anyone can help me?

Here is my code

Private Sub AmountTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles AmoutTextBox.KeyPress

        Dim allowedChars As String = "0123456789"

        If allowedChars.IndexOf(e.KeyChar) = -1 Then
            ' Invalid Character
            e.Handled = True
        End If

    End Sub
2
Contributors
2
Replies
10
Views
7 Years
Discussion Span
Last Post by TrueVb.NetNoob
0

Hi,

I have modified the code to allow back space. Please find the code below.

Dim allowedChars As String = "0123456789"
        If e.KeyChar <> ControlChars.Back Then
            If allowedChars.IndexOf(e.KeyChar) = -1 Then
                ' Invalid Character
                e.Handled = True
            End If
        End If
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.