PRB: Format Function May Return Incorrect Values (174155)
The information in this article applies to:
- Microsoft Visual Basic Control Creation Edition for Windows 5.0
- Microsoft Visual Basic Learning Edition for Windows 5.0
- Microsoft Visual Basic Professional Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
- Microsoft Visual Basic Standard Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 32-bit, for Windows 4.0
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.
Modification Type: | Minor | Last Reviewed: | 2/24/2005 |
---|
Keywords: | kbbug kbfix kbprb kbVBp600fix KB174155 |
---|
|