Results 1 to 3 of 3

Thread: Percent into textbox

  1. #1

    Thread Starter
    Addicted Member Lee_S's Avatar
    Join Date
    Dec 2000
    Location
    New Zealand
    Posts
    250

    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

  2. #2
    Megatron
    Guest

  3. #3
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    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
  •  



Click Here to Expand Forum to Full Width