Results 1 to 3 of 3

Thread: Rounding currency to nearest 5cents [RESOLVED]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Location
    Wollongong. NSW. Australia
    Posts
    470

    Thumbs up Rounding currency to nearest 5cents [RESOLVED]

    G'day,

    I have to round a currency total to the nearest 5 cents. Is there an inbuilt function to do it better?
    VB Code:
    1. Dim temp As Currency
    2.    temp = TotalCost * 10 - Int(TotalCost * 10)
    3.    If temp < 0.5 Then
    4.      TotalCost = TotalCost - temp/10
    5.    ElseIf temp > 0.5 Then
    6.       TotalCost = Round(TotalCost + 0.05, 1)
    7.    End If
    Peter
    Last edited by Supremus; Jun 21st, 2005 at 01:58 AM.
    My reputation is in tatters. Don't bother trying to repair it.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Rounding currency to nearest 5cents

    this seems to work ok

    charge = 9.37
    mycharge = (CDbl(charge * 100 \ 5)) / 20

    pete

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2005
    Location
    Wollongong. NSW. Australia
    Posts
    470

    Re: Rounding currency to nearest 5cents

    G'day Pete,

    Sure does, and a lot simpler.

    Thanks.
    My reputation is in tatters. Don't bother trying to repair it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width