QB.EXE Editor Fails to Flag Extra ELSE Clause as Syntax Error (37319)






This article was previously published under Q37319

SYMPTOMS

In the program code example below, the QB.EXE environment fails to detect an extra ELSE clause in an IF statement as being a syntax error. Instead, the number 0 is displayed as well as number 2.

The BC.EXE compiler successfully flags the extra ELSE clause as a syntax error. It is logically illegal to use two or more ELSE clauses in an IF statement. Only one ELSE clause is allowed in an IF statement. (The ELSE clause can also be left out of an IF statement.)

STATUS

Microsoft has confirmed this to be a bug in QuickBasic Versions 4.00, 4.00b, and 4.50. This problem is corrected in the QBX.EXE environment that comes with Microsoft Basic PDS Version 7.00 (fixlist7.00).

The following is a code example:
a = 0
IF a = 0 THEN
  PRINT a
ELSE
  PRINT 1
ELSE
  PRINT 2
END IF
				

Modification Type: Minor Last Reviewed: 1/9/2003
Keywords: KB37319