Explanation
IF...THEN...ELSE Statement
Executes a statement or statement block depending on specified conditions.Worth knowing
Useful and cross-version information about the programming environments of QBasic, QuickBasic and Visual Basic for DOS.
Useful and cross-version information about the programming environments of QBasic, QuickBasic and Visual Basic for DOS.
IF condition1 THEN [statementblock-1] [ELSEIF condition2 THEN [statementblock-2]]... [ELSE [statementblock-n]] END IF IF condition THEN statements [ELSE statements] |
condition1 condition2 |
Any expression that can be evaluated as true (nonzero) or false (zero). |
statementblock-1 statementblock-2 statementblock-n |
One or more statements on one or more lines. |
statements | One or more statements, separated by colons. |
INPUT "1 or 2? ", i%
IF i% = 1 OR i% = 2 THEN
PRINT "OK"
ELSE
PRINT "Out of range"
END IF
See also: | ON GOSUB, ON GOTO | SELECT CASE |