-
Percent into textbox
Hi guys, some advice on this would be great.
What i need is a textbox for the input of a percentage, accurate to 2 decimal places. So, i need some sort of function that can be used for both keypress and validation events, if possible.
Ie, valid entries would be 34.55, 100, 9, 0.99.
Invalid would be .9765, 2.4.5, 104.45 etc.
Anyone have anything like this lying about? All the examples i've found so far dont really do it.
lee
-
-
try this
Code:
Sub ForceNumeric(Keyascii, CControl as Control)
Dim intKeyAscii as Integer
intKeyascii=0
If Keyascii>= asc(0) and Keyascii <= Asc(9) then intKeyascii=Keyascii
if Keyascii=8 then intKeyascii=8
This allow one decimal but not two
if keyascii=46 and instr(CCONTROL,".") then
keyascii=0
elseif keyascii=46 then
intkeyascii=46
end if
keyascii=intkeyascii
end sub
'Place in textbox Keypress Envent
Call ForceNumeric(Keyascii,Me.ActiveControl)
Luck to you...