WinXP and VB 6 Format$
Posted on 2002-04-16
We are having trouble with the format$ command under Windows XP.
It has to do with rounding of numbers to 2 decimal places (eg Format$(ANumber, "0.00").
If you pass in a number such as 1.23, it works fine.
If you pass in 1.265, the result is 1.27 - this is ok.
If you pass in 1.257, the result is 1.26 - this is ok.
If you pass in 1.253, the result is 1.25 - this is ok.
If you pass in 1.235, the result is 1.23 - incorrect!
If you pass in 1.236, the result is 1.23 - incorrect!
If you pass in 1.239, the result is 1.23 - incorrect!
It appears to look at the second decimal place when evaluating the 3rd and subsequent places. If the 2nd number is < 5, then it ignores any possible rounding on the 3rd digit.
We have tried to "over ride" the format function by declaring our own, and if it meets any other criteria other than "0.00", we pass it out to VBA.Format$, otherwise we manipulate the code to round the number accordingly, but we think that this is a dangerous practice, and we are reluctant to release software with this in it.
Has anyone seen this, and if so, do they have an alternate solution?