forked from QB64-Phoenix-Edition/QB64pe
-
Notifications
You must be signed in to change notification settings - Fork 0
CASE ELSE
Samuel Gomes edited this page Nov 8, 2022
·
1 revision
See SELECT CASE.
CASE ELSE is used in a SELECT CASE procedure as an alternative if no other CASE statements are true.
- 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.
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
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