ELSE

From QB64 Wiki

Revision as of 19:33, 1 June 2011 by Clippy (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

ELSE is used in IF...THEN or SELECT CASE statements to offer an alternative to other conditional statements.


  • ELSE is used in a IF block statement to cover any remaining conditions not covered in the block by IF or ELSEIF.
  • CASE ELSE covers any remaining conditions not covered by the other CASE statements.
  • ELSE can also be used as a False comparison to a True IF statement when a condition will only be True or False.


Example 1: One line IF statement

IF x = 100 THEN PRINT "100" ELSE PRINT "Not 100"

Example 2: Multiple line IF statement block

IF x = 100 THEN ' code executed MUST be on next statement line! PRINT "100" ELSE PRINT "Not 100" END IF


Example 3: To alternate between any two values (as long as the value after ELSE is the same as the condition)

IF a = 3 THEN a = 5 ELSE a = 3


See also:



Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page