CASE ELSE - QB64 Wiki

CASE ELSE

From QB64 Wiki

Jump to: navigation, search

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 supercede any case statements after it.
  • Use it as a "safety net" or as an alternative for ALL values not covered in the CASE statements.


Code 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:



Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page
Views
  • Page
  • Discussion
  • View source
  • History
Personal tools
  • Log in
Toolbox
  • What links here
  • Related changes
  • Special pages
  • Printable version