Rounding a number

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • AA

    Rounding a number

    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


  • JSand42737

    #2
    Re: Rounding a number

    In article <bt42uf$7cm$1@c tb-nnrp2.saix.net> , "AA" <Alfredminnaar@ hotmail.com>
    writes:
    [color=blue]
    >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[/color]

    Alfred

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

    Public Function fRound5Cent(cur Amount 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 & "fRound5Cen t", vbOKOnly + vbCritical,
    "Error: " & Err.Number
    Resume fExit
    End Function


    --

    Jon

    www.applecore99.com - Access Tips and Tricks

    Comment

    Working...