|
-
Oct 14th, 2001, 12:26 PM
#1
Thread Starter
Addicted Member
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
-
Oct 14th, 2001, 01:12 PM
#2
-
Oct 14th, 2001, 01:20 PM
#3
PowerPoster
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...
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
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
|