Monday, November 23, 2009

How to Make a Textbox Accept Only Numbers

First, you must make the textbox itself :)
Then, go to it's keypress events and add the code below :

If Char.IsNumber(e.KeyChar) = False And Char.IsControl(e.KeyChar) = False Then
e.Handled = True
End If

Now, simply test it...