Microsoft KB Archive/43264

= Variables Not Allowed in CASE Statement of SELECT CASE Block =

Article ID: 43264

Article Last Modified on 11/21/2006



This article was previously published under Q43264



SUMMARY
The SELECT CASE block does not allow variables in the CASE statements. As an alternative, using multiple IF statements is recommended.

Code Example

The following code example gives a &quot;Syntax Error&quot; on the CASE x line: x=1 y=1 SELECT CASE y CASE 0 PRINT &quot;Zero&quot; CASE x               ' This line causes error PRINT &quot;XXX&quot; CASE ELSE END SELECT This is an example of the workaround using multiple IF statements: x=1 y=1 IF y=0 THEN PRINT &quot;Zero&quot; ELSEIF y=x THEN PRINT &quot;XXX&quot; ELSE END IF

Additional query words: MQuickB

Keywords: KB43264

-

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

© Microsoft Corporation. All rights reserved.