suicehockey44
asked on
TextBox as Percentage
Hi. I basically want a text box entry to be a percentage. So, if the user enters 100 its 100 percent of a value. 50 would be 50 percent (.50) and so on. In the database its simply a decimal. How would I go about doing this?
Thanks!!!
Thanks!!!
I Think you are asking a Type casting question
also you might want to sanitize the input to make sure it is within range of percentages (less than 1 and greater than 0)
also you might want to sanitize the input to make sure it is within range of percentages (less than 1 and greater than 0)
Function getValue(TextBox tb)
Dim percent As Double
'Cast String to double
percent = CDBL(tb.value)
IF( (percent/100) <= 1 and (percent/100) >= 0 )
getValue = percent
ELSE
'invalid percentage value
ENDIF
ENDF
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window