0

I want to validate a textbox so that only numeric values can be inserted in to it.
This validation should done while user enters the values.
For example.
Consider following keys had been pressed in a sequence

12345abcd678


only numeric values should appear in the textbox

so value which should be displayed in the textbox is
12345678

Any suggesions????? Please comment

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by kimbula...
1
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If Asc(e.KeyChar) >= 48 And Asc(e.KeyChar) <= 57 Then
            e.Handled = False
        Else
            e.Handled = True
        End If
    End Sub
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.