How could i only allow the user to type in numbers? (. allowed because of decimal points) and only 1 decimal point?
Printable View
How could i only allow the user to type in numbers? (. allowed because of decimal points) and only 1 decimal point?
You can try this control of MartinLiss.
Search the forum for "only number textbox" or "numerical textbox" etc. But there are many complications to making this working properly, without cursor jumping around, then to think about pasting using keyboard, pasting using the right-click popup menu etc.
With modern computers, unless you're in a situation where fractions of seconds are important, just go through each character, Mid(.text,var,1), on the change event... it fires for keypresses, paste, and even WM_SETTEXT (which makes it useful for rudimentary interprocess communication).
You could also try to use the Masked Edit Control text box by adding the Microsoft Masked Edit Control component to your project. The mask of ####.# will allow numbers in the thousands and only one decimal.
Hmm... Okay. THanks all for examples. =D