Round to 2 decimal places

A

Alan T

I want to round the calculation to 2 decimal places:
eg.
(215 * 3.134)/100

Any function I can use with?
 
R

ruralguy via AccessMonster.com

Have you looked at the Round() function?

Alan said:
I want to round the calculation to 2 decimal places:
eg.
(215 * 3.134)/100

Any function I can use with?
 
G

Guy

Alan,

A slightly more complex response...

Do you want to use Bankers rounding or Arithmetic rounding?

From memory VBA uses Bankers rounding, SQL Server Arithmetic rounding.

Here is a VBA rountine that applys arithmetic rounding:

Public Function gfnRound(varNumber As Variant, lngNumDecimalPlaces As Long)
As Variant
'*******************************************************************************
' Arithmetic rounding
'
' Return Value: variant
'
' Called By: Many
'
' Note. The VBA Round function uses banker's rounding
'*******************************************************************************
Dim dblPower As Double
Dim intSgn As Integer

If IsNumeric(varNumber) Then
dblPower = 10 ^ lngNumDecimalPlaces
intSgn = Sgn(varNumber)
gfnRound = (intSgn * Int(CDec(Abs(varNumber)) * dblPower + 0.5)) /
dblPower
End If
End Function

Hope this helps

Guy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top