Microsoft KB Archive/65504

= Basic &quot;Statements/Labels Illegal Between SELECT CASE and CASE&quot; =

Article ID: 65504

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 7.0
 * Microsoft BASIC Professional Development System 7.1

-



This article was previously published under Q65504



SUMMARY
Line numbers are allowed in most Basic source statements. One area line numbers are not allowed in is an area of Basic's SELECT CASE statement. If a line number precedes the first CASE ExpressionList part of the statement, the error &quot;Statements/labels illegal between SELECT CASE and CASE&quot; will be returned.

This information applies to Microsoft QuickBasic versions 4.00, 4.00b, and 4.50 for MS-DOS; to Microsoft Basic Compiler versions 6.00 and 6.00b for MS-DOS and MS OS/2; and to Microsoft Basic Professional Development System (PDS) versions 7.00 and 7.10 for MS-DOS and MS OS/2.



MORE INFORMATION
The first versions of Basic (interpreter) required line numbers for every line. For upward compatibility, this feature is still available in the newer Basics. Some statements that are new to the language, however, restrict the use of the line number feature. One such statement is the SELECT CASE statement. Line numbers are allowed anywhere in the statement except between the SELECT CASE TextExpression and the first CASE ExpressionList.

This limitation can be inconvenient to a programmer who wants to use line numbers in each line so that the ERL function can report the line on which an error occurred. However, with syntax checking turned on in QB.EXE or QBX.EXE, it is very unlikely an error will exist.

The code example below demonstrates this discussion.

Code Example
CLS INPUT &quot;Enter acceptable number (1-10): &quot;, num '  Line numbers are OK to use on the SELECT statement: 10    SELECT CASE num ' The following statement generates the error &quot;Statements/labels ' illegal between SELECT CASE and CASE&quot;: 15     CASE IS = 10 ' Removing the &quot;15&quot; eliminates the error. '  It is OK to put line numbers inside of the rest of the CASE: 20        PRINT &quot;Maximum number&quot; CASE 6 TO 9 PRINT &quot;Higher, but not the maximum&quot; CASE 2 TO 5 PRINT &quot;Moderate picker, aren't you&quot; CASE 1 PRINT &quot;A low number indeed&quot; CASE ELSE PRINT &quot;RESPONSE OUT OF RANGE&quot; END SELECT

Additional query words: QuickBas BasicCom

Keywords: KB65504

-

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

© Microsoft Corporation. All rights reserved.