i have 3 text boxes and am using them to do a simple subtraction between them. The problem is when I input a non-numerical character, i get a type-mismatch error. How can I get around this?
Thanks,
Printable View
i have 3 text boxes and am using them to do a simple subtraction between them. The problem is when I input a non-numerical character, i get a type-mismatch error. How can I get around this?
Thanks,
Try a search, this is a very common question.
Arguably the best way would be to use the NumberBox control you can create from the NumberBox ActiveX control link in my signature.
if you use val(text1.text) or whatever, it returns a legal integer no matter what. Non-numeric entries after a numeric entry (example: 123fg) are ignored and this example would end up being 123. and if it is non-numeric ONLY ("lord") then it returns a zero. Seems like a better idea though would be to limit the text inputted. And make sure you take into account copy/paste operations also.
Remember Val is not locale aware. Less than half of the countries of the world use the dot as a decimal separator.
true...
Fortunately, whole numbers are expected in this application. However, how could decimal indicators be allowed?
Thanks,
If you compile and use my control you will be able to use two new properties with which you can define if the NuberBox will allow decimals and if it does you can specify how many decimals.Quote:
Originally Posted by atanq