|
-
Oct 20th, 2007, 04:45 PM
#1
Thread Starter
Lively Member
[RESOLVED] numbers in text boxes
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,
-
Oct 20th, 2007, 04:55 PM
#2
Re: numbers in text boxes
Try a search, this is a very common question.
-
Oct 20th, 2007, 06:27 PM
#3
Re: numbers in text boxes
Arguably the best way would be to use the NumberBox control you can create from the NumberBox ActiveX control link in my signature.
-
Oct 20th, 2007, 09:30 PM
#4
Re: numbers in text boxes
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.
-
Oct 21st, 2007, 04:03 AM
#5
Re: numbers in text boxes
Remember Val is not locale aware. Less than half of the countries of the world use the dot as a decimal separator.
-
Oct 21st, 2007, 07:58 AM
#6
Re: numbers in text boxes
-
Oct 21st, 2007, 01:45 PM
#7
Thread Starter
Lively Member
Re: numbers in text boxes
Fortunately, whole numbers are expected in this application. However, how could decimal indicators be allowed?
Thanks,
-
Oct 21st, 2007, 01:58 PM
#8
Re: numbers in text boxes
 Originally Posted by atanq
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|