Results 1 to 3 of 3

Thread: Automatic rounding up of number?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    1

    Automatic rounding up of number?

    hi first time here, i am making a program to calculate postage costs. and on a loop that is in the program when it does the sum of 3.45 + 0.86 it comes up with 4.30 when it should be 4.31

    The loop Code:
    1. Dim extracost As Currency
    2.         Dim loopcost As Currency
    3.         Dim extracostformated As Currency
    4.         Dim loopcostformated As Currency
    5.         loopcost = 3.45
    6.         extracost = 0.86
    7.         loopcostformated = FormatNumber(loopcost, 2)
    8.         extracostformated = FormatNumber(extracost, 2)
    9.         Cost = loopcostformated And Weight = Weight - 1000
    10.         Do While Weight > 0
    11.         Weight = Weight - 250
    12.         Cost = Cost + extracostformated
    13.         Loop
    Last edited by joshbro90; May 15th, 2007 at 02:13 PM.

  2. #2
    Fanatic Member Andy_P's Avatar
    Join Date
    May 2005
    Location
    Dunstable, England
    Posts
    669

    Re: Automatic rounding up of number?

    Hi, welcome to the forums!

    You may have more luck with this question if you post it in the Classic VB forum.
    Using Windows XP Home sp3
    Mucking around with C# 2008 Express
    while ( this.deadHorse ) { flog( ); }


  3. #3
    Addicted Member TBeck's Avatar
    Join Date
    Apr 2006
    Location
    Ontario, Canada
    Posts
    254

    Re: Automatic rounding up of number?

    i believe formatNumber is used only for outputting a string representation of the number, so try formatNumber on the result, not the numbers used for the calculations

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