VAT field calculation?

GJT

Registered User.
Local time
Today, 20:58
Joined
Nov 5, 2002
Messages
116
I have a textbox on a form that calculates VAT for transactions whose controlsource property is :

=([txtSubtotal]*0.175)

The trouble I am having is with the rounding that seems takes place in the control. If the fractional part of a value is calcuated it is rounded in accordance with the following :

When the fractional part is exactly 0.5, control always rounds it to the nearest even number. (For example, 0.5 rounds to 0, and 1.5 rounds to 2).

i need to ensure that the VAT is rounded (either up/down) in ALL cases. Any ideas people?

Thanks

Guy
 
Round up:

=Int(([txtSubtotal]*0.175) + 0.5)

Round down:

=Int(([txtSubtotal]*0.175) - 0.5)
 
Thanks.

But what about when its not 0.5 i.e

0.364 OR 0.747?????
 
GJT said:
Thanks.

But what about when its not 0.5 i.e

0.364 OR 0.747?????


Int(0.354 + 0.5) = Int(0.854) => Int removes the fraction, leaving the nearest whole number, 0.

Int(0.747 + 0.5) = Int(1.247) => Int removes the fraction, leaving the nearest whole number, 1.


And, actually, on re-reading your problem yu want it ALL to ROUND UP in every instance, o for ALL to ROUND DOWN in every instance.

If you round down you can just use INT to perform this.
To round up, add 1 and use the INT function.
 
your solution seems to hardcoding numbers into the controlsource property for the control! This is not acceptable.

Also, I am working with decimal numbers i.e. 37.7533659

in this instance : How could I get the desired figure 37.75 ?
 
Multiply it by 100, use the Int function, divide it by 100. ;)
 

Users who are viewing this thread

Back
Top Bottom