Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/35666

From BetaArchive Wiki
Knowledge Base

In QB.EXE, Improper FOR NEXT Control after NEXT Is Inserted

Article ID: 35666

Article Last Modified on 11/21/2006

This article was previously published under Q35666


In the QB.EXE editor, when a NEXT statement is inserted inside a nested FOR NEXT loop after a "FOR WITHOUT NEXT" error has occurred, loop control is incorrectly executed.


Microsoft has confirmed this to be a bug in Microsoft QuickBasic Versions 4.00, 4.00b, and 4.50, and in the QB.EXE that comes with the Microsoft Basic Compiler Versions 6.00 and 6.00b for MS-DOS and MS OS/2 (buglist6.00, buglist6.00b). This problem was corrected in the Microsoft Basic PDS Version 7.00 (fixlist7.00).


To duplicate this problem, do the following:

  1. Enter the following code in the QuickBasic editor:

          FOR k = 1 to 5
            FOR l = 1 to 2
              PRINT k

    Running this will give the FOR WITHOUT NEXT error.

  2. Insert another NEXT statement after the "PRINT k" and run the program again.

    The output should be as follows:

          1   1   2   2   3   3   4   4   5   5

    However, it is as follows:

          1   1   2   2

    If the NEXT is inserted after the already existing NEXT, the program runs correctly.

Additional query words: QuickBas BasicCom buglist4.00 buglist4.00b buglist4.50 B_BasicCom

Keywords: KB35666