ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   TextBox that only accepts integers? (https://www.excelbanter.com/excel-programming/320087-textbox-only-accepts-integers.html)

Claud Balls

TextBox that only accepts integers?
 
What would be the best way to check that text is a positive whole
number? I'm thinking about putting it in the textbox_exit event.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Harald Staff

TextBox that only accepts integers?
 
Hi

Exit is too late. Use the Keypress event. Set keyascii to 0 if its < 48 or
57.


Except (tricky part coming up): Keydown event to trap and validate Ctrl V.

HTH. Best wishes Harald

"Claud Balls" skrev i melding
...
What would be the best way to check that text is a positive whole
number? I'm thinking about putting it in the textbox_exit event.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




Jim Thomlinson[_3_]

TextBox that only accepts integers?
 
You can validate the contents of the textbox using the isnumeric function.
You will also have to look for "-" and "." using the instr function.


"Claud Balls" wrote:

What would be the best way to check that text is a positive whole
number? I'm thinking about putting it in the textbox_exit event.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



All times are GMT +1. The time now is 10:36 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com