PDA

Click to See Complete Forum and Search --> : Automatic rounding up of number?


joshbro90
May 15th, 2007, 02:06 PM
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

Dim extracost As Currency
Dim loopcost As Currency
Dim extracostformated As Currency
Dim loopcostformated As Currency
loopcost = 3.45
extracost = 0.86
loopcostformated = FormatNumber(loopcost, 2)
extracostformated = FormatNumber(extracost, 2)
Cost = loopcostformated And Weight = Weight - 1000
Do While Weight > 0
Weight = Weight - 250
Cost = Cost + extracostformated
Loop

Andy_P
May 15th, 2007, 03:38 PM
Hi, welcome to the forums!

You may have more luck with this question if you post it in the Classic VB forum. :)

TBeck
May 15th, 2007, 08:48 PM
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