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:
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
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. :)
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