FIX: INT Function Returns Incorrect Value

Last reviewed: October 30, 1997
Article ID: Q138522
3.00 WINDOWS kbprg kbbuglist

The information in this article applies to:

  • Standard and Professional Editions of Microsoft Visual Basic for Windows, version 3.0

SYMPTOMS

The INT function may, in some cases, return an incorrect value.

RESOLUTION

To work around this problem, don't perform a calculation inside the INT function. Assign the result to a variable and use the INT function on that variable. You can use the following sample code to convert your variable to an integer:

    Dim Result as Double
    Result = 3^2
    Print INT(Result)

STATUS

Microsoft has confirmed this to be a bug in Microsoft Visual Basic Version 3.0 for Windows. This problem was corrected in Microsoft Visual Basic Version 4.0 for Windows.

MORE INFORMATION

Steps to Reproduce Problem

  1. Start a new project in Visual Basic version 3.0. Form1 is created by default.

  2. Place the following code in the Click event for the form:

    Print INT(3^2)

  3. Run the program, and click the form. An 8 prints instead of the expected 9.


Additional reference words: 3.00 buglist3.00 fixlist4.00
KBCategory: kbprg kbbuglist
KBSubcategory: PrgOther
Keywords : PrgOther kbbuglist kbprg
Version : 3.00
Platform : WINDOWS
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.