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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Round Down 3

Status
Not open for further replies.

turnerk200

Programmer
Mar 9, 2004
20
0
0
AU
Hi, I have a simple bit of code that makes a calculation (see below), then rounds it to 2 decimal places, but it always rounds it up, I need it to round down. I've looked through here and I'm sure it's simple but cant work it out! Any help would be greatly appreciated.
Thanks,

Dim intBPS As Double

If Me.txtFundDollars > 0 Then
intBPS = Me.ErrorAmt / Me.txtFundDollars * 100
intBPS = Round(intBPS, 2)
Me.ErrorBPS = intBPS
End If
 
Try using integer division in your calculation.

For example:

23456 / 100 = 234.56 (ordinary division - forward slash)
but
23456 \ 100 = 234 (integer division - backslash)

This always rounds down:

23499 \ 100 = 234

In your formula, I would try something like:

Code:
    intBPS = Me.ErrorAmt / Me.txtFundDollars * 10000
    intBPS = intBPS \ 100


Bob Stubbs
 
BobStubbs, thanks for that post - just happened upon it, and learned something new - may be useful at some point. Have a star!

Stephen [infinity]
"Jesus saith unto him, I am the way, the truth, and the life:
no man cometh unto the Father, but by me." John 14:6 KJV
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top