OK guys, I want to have a few textboxes that only accept numerical chars, not letters. Therefore I need some sort of validation as soon as the user has entered something into the textboxes to prevent this. I have demonstrated this below in a basic way, whereby if the user enters a letter ?a? then they will get an error message, however it will still leave the letter a in the textbox which is no good. Plus I need it for all the alphabet, not just ?a?. There must be an easier way todo what I require, can anyone help?
Private Sub TextBox2_Change()
If TextBox2 = ?a? Then MsgBox "Enter Numerical characters only "
Question
rageagainstmachine
OK guys, I want to have a few textboxes that only accept numerical chars, not letters. Therefore I need some sort of validation as soon as the user has entered something into the textboxes to prevent this. I have demonstrated this below in a basic way, whereby if the user enters a letter ?a? then they will get an error message, however it will still leave the letter a in the textbox which is no good. Plus I need it for all the alphabet, not just ?a?. There must be an easier way todo what I require, can anyone help?
Private Sub TextBox2_Change()
If TextBox2 = ?a? Then MsgBox "Enter Numerical characters only "
Link to comment
Share on other sites
5 answers to this question
Recommended Posts