By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,505 Members | 1,549 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,505 IT Pros & Developers. It's quick & easy.

Rounding a number

P: n/a
AA
Hi
I Have a till program that must round the change to the nearest 5cent
Ex. Amout tendered $130.00 Total owed R125.36 Change $4.64 The 4.64cents
must now be rounded up to the nearest 5cent namely $4.65

Any idea how to do this ?
Thanks
Alfred
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In article <bt**********@ctb-nnrp2.saix.net>, "AA" <Al***********@hotmail.com>
writes:
Hi
I Have a till program that must round the change to the nearest 5cent
Ex. Amout tendered $130.00 Total owed R125.36 Change $4.64 The 4.64cents
must now be rounded up to the nearest 5cent namely $4.65

Any idea how to do this ?
Thanks
Alfred


Alfred

The small function below rounds up to the nearest 5 cents:

Public Function fRound5Cent(curAmount As Currency) As Currency
On Error GoTo E_Handle
If Int(curAmount / 0.05) = (curAmount / 0.05) Then
fRound5Cent = curAmount
Else
fRound5Cent = (Int(curAmount / 0.05) + 1) * 0.05
End If
fExit:
On Error Resume Next
Exit Function
E_Handle:
MsgBox Err.Description & vbCrLf & "fRound5Cent", vbOKOnly + vbCritical,
"Error: " & Err.Number
Resume fExit
End Function
--

Jon

www.applecore99.com - Access Tips and Tricks

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.