Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rounding Issues

Status
Not open for further replies.

willsth

Programmer
Oct 3, 2008
33
GB
I am trying to round-up a result field, it seems to round-down when I use the Round function
 
I found the following bit of code on the following website

Function AsymArith(ByVal X As Double, _
Optional ByVal Factor As Double = 1) As Double
AsymArith = Int(X * Factor + 0.5) / Factor
End Function

When I use it as follows :-
Private Sub Billable_Hours_AfterUpdate()
Me.TxtCost = Me![Billable Hours] * Me![TxtRate]
Me.TxtCost = AsymArith(Me.TxtCost, 100)
End Sub

I get the following result :-
Billable Hours(1.5) * TxtRate(4.09) = 6.135
Rounded to 6.13 NOT 6.14

I thought AsymArith would always round .5 upwards
 
there are any number of rounding procedures (function) in these fora (Tek-Tips) use advanced search with just the term "Round". At least one of these permits the specification of the precision (# decimal places).




MichaelRed


 
That is not possible. That function only rounds to integers. But if you use the one I provided and set the precision to 2 decimal places the answer is 6.14.
 
I think that's cracked it.

Thanks very much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top