Article ID: 174155
Article Last Modified on 2/24/2005
APPLIES TO
- Microsoft Visual Basic 5.0 Control Creation Edition
- Microsoft Visual Basic 5.0 Learning Edition
- Microsoft Visual Basic 5.0 Professional Edition
- Microsoft Visual Basic 5.0 Enterprise Edition
- Microsoft Visual Basic 4.0 Standard Edition
- Microsoft Visual Basic 4.0 Professional Edition
- Microsoft Visual Basic 4.0 Professional Edition
- Microsoft Visual Basic 4.0 16-bit Enterprise Edition
- Microsoft Visual Basic 4.0 32-Bit Enterprise Edition
This article was previously published under Q174155
SYMPTOMS
Decimal values rounded by the Format function may be incorrect. For a
specific decimal number, the rounded value returned by the Format function
may differ for different data types and between different versions of
Microsoft Visual Basic.
CAUSE
When a variable is passed into the Format function, an algorithm is used to
determine the most appropriate numeric data-type to convert the value to,
and how to format it. This algorithm may not evaluate certain decimal
values as expected.
RESOLUTION
To avoid these unexpected conversions, explicitly convert the value to the
desired data type before using the Format function. For instance, use the
CCur function to convert the decimal value to a currency data-type that
maintains more accuracy in rounding.
STATUS
Microsoft has confirmed this to be a problem in the Microsoft products
listed at the beginning of this article. This problem does not occur in
Visual Basic 6.0.
Additional query words: Precision
Keywords: kbbug kbfix kbvbp600fix kbprb KB174155