PlayKid Posted August 21, 2005 Posted August 21, 2005 Dear all, How do I do that? To prevent user from entering "abcd", the user may only enter "1234"..... Say if the user enter something that's not numeric, then the textbox won't response.... Thanks PlayKid Quote
jmcilhinney Posted August 21, 2005 Posted August 21, 2005 This question is definitely in the top 10 most asked. Do a forum search and you'll find your answer. Quote
techmanbd Posted August 22, 2005 Posted August 22, 2005 Private Sub txtCalledNumber_KeyPress(ByVal sender As System.Object, ByVal e As KeyPressEventArgs) Handles txtCalledNumber.KeyPress If Not Char.IsNumber(e.KeyChar) And Not Asc(e.KeyChar) = Keys.Back Then e.Handled = True End If End Sub kEYS.BACK is for the back space. That way if you make a mistake you can still use the backspace key Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
*Experts* Bucky Posted August 22, 2005 *Experts* Posted August 22, 2005 If you use techmanbd's code and you want the user to be able to enter decimals, then make sure you allow the "." character as well. Or just skip all the validation and use a NumericUpDown control. Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.