How to create validation on textbox using Visual Basic?
I have a textbox that will accept the quantity of products ordered.
It should allow only numbers.
Thanks
I have a textbox that will accept the quantity of products ordered.
It should allow only numbers.
Thanks
Â
Your code does the job. But  if  the user input is not number, the whole text is erased. what I want is that the textbox will not allow other keys except numbers and still not remove previous numbers inputted by the user.
Thanks
Aside from the is numeric function, you can also use the keypress. follow this code and give it a try
Private Sub Text1_KeyPress(KeyAscii as Integer)Â
'Ignore negativesÂ
If KeyAscii = 45 then goto EndProcÂ
'If Key pressed is not numeric then make key NullÂ
If (KeyAscii < 48) or (Keyascii >57) then KeyAscii = 0Â
Endproc:Â
End SubÂ
That's a nice idea Mr Techgeek.. That textbox will look more professional using your code..
Thanks for the knowledge you’ve shared with me. It can help a lot for my project. thanks again.
You're always welcome.. feel free to ask here in techyv if you have problems.
A lot of expert here will help you..