VB Code:
Text20 = CInt(Text15.Text) * CInt(Text13.Text) + CInt(Text11.Text) * 12 / 52 * CInt(Text13.Text)
how can i round the text20 to 2 decimal places? :blush: :blush: :confused:
Printable View
VB Code:
Text20 = CInt(Text15.Text) * CInt(Text13.Text) + CInt(Text11.Text) * 12 / 52 * CInt(Text13.Text)
how can i round the text20 to 2 decimal places? :blush: :blush: :confused:
Try This
Decimal.Round( YourMathExpression, 2)
Note that decimal.Round employs bankers rounding. (Do a google search if you don't know what this is)
If you want decimal places I wouldn't use int(egers) as these do no have places... normally ;)
I'd use doubles and only format the end resulting calculation otherwise you'd get calculation errors from one to another calc.
cdbl for the function.
Although I think there may be problems with the accuracy as it is floating point :/ other people can comment on that.
Experiment with it and see which way gives you the results you want.Code:dblTemp = Cdbl(Text15.Text) * Cdbl(Text13.Text) + (Cdbl(Text11.Text) * 12) / (52 * Cdbl(Text13.Text))
Text20 = format(dblTemp,"#,#0.00")
no luck.. :confused:
Here is an idea for you:
Create a new variable as a string version of your number.
With that, split the number using Mid$() to get the actual decimal you want to check.
Then, turn that back into a number and check if it is below or above 5 and go from there :)
Cheers,
RyanJ
thanx man!! when i postedthat was for the guy that told me to use decimal.round... but u posted just before me lol, and thanx! it works!Quote:
no luck :confused:
:wave: