954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Validate a textbox

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

kimbula...
Newbie Poster
14 posts since Jun 2009
Reputation Points: 9
Solved Threads: 0
 
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
sonia sardana
Posting Whiz
326 posts since Mar 2008
Reputation Points: 0
Solved Threads: 8
 

hi kimbula, if u get answer to ur question, mark this thraed as solved,so dat it will be helpfull for others also

sonia sardana
Posting Whiz
326 posts since Mar 2008
Reputation Points: 0
Solved Threads: 8
 

Sorry for my delayed actions.
Thank you very much. This is working
Awesome

kimbula...
Newbie Poster
14 posts since Jun 2009
Reputation Points: 9
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You