CASE ELSE
Redirect page
Jump to navigation
Jump to search
Redirect to:
CASE ELSE is used in a SELECT CASE procedure as an alternative if no other CASE statements are true.
Description
- CASE ELSE should be listed at the bottom of the case list as it will supersede any case statements after it.
- Use it as a "safety net" or as an alternative for all values not covered in the CASE statements.
Examples
Example 1:
a = 100 SELECT CASE a CASE IS < 99: PRINT "a is < 99" CASE 99: PRINT "a is 99" CASE IS > 100: PRINT "a is > 100" CASE ELSE PRINT "a is 100" END SELECT
a is 100
Example 2:
a = 100 SELECT CASE a CASE 10: PRINT "a is 10" CASE 20: PRINT "a is 20" CASE 30: PRINT "a is 30" CASE ELSE: PRINT "a is something other than 10, 20 and 30" END SELECT
a is something other than 10, 20 and 30
See also