Microsoft KB Archive/149319

= FIX: String/Currency Conversion Broken with Sci. Notation =

Article ID: 149319

Article Last Modified on 6/30/2004

-

APPLIES TO


 * 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 Q149319



SYMPTOMS
Visual Basic 4.0 will sometimes return an incorrect value when converting a string to a currency value if the string contains a large number represented using scientific notation.



CAUSE


RESOLUTION
To work around the problem, append zeroes to the end of the string to be converted. This will cause the correct result. For example, instead of using Print 1.7e7@, use Print 1.7000000000e7@. Nine zeroes will fix the problem in the worst case. The smaller the exponent, the fewer zeroes need to be added to obtain correct behavior.



STATUS
Microsoft has confirmed this to be a problem in the products listed above. This problem has been fixed in Microsoft Windows 98.



Steps to Reproduce
 Start Visual Basic or, if it is already running, choose New Project from the File menu.  Insert this line of code into the Form_Load event: Private Sub Form_Load Stop End Sub  Select Start from the Run menu, or press the F5 key to start the application. Switch to the Debug window, enter Print 1.7e7@, and press the ENTER key. You will see the incorrect value of 7798.8435 instead of the correct 17000000. Using Print 1.7000000000e7@ instead will cause the correct response.

Keywords: kbbug kbfix kboswin98fix KB149319

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.