qbasic.hlp (Topic list)
SELECT CASE Statement
  Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
Executes one of several statement blocks depending on the value of an
expression.
 
SELECT CASE testexpression
CASE expressionlist1
  [statementblock-1]
[CASE expressionlist2
  [statementblock-2]]...
[CASE ELSE
  [statementblock-n]]
END SELECT
 
    ■ testexpression      Any numeric or string expression.
    ■ expressionlist1     One or more expressions to match testexpression.
      expressionlist2     The IS keyword must precede any relational operators
                          in an expression.
    ■ statementblock-1    One or more statements on one or more lines.
      statementblock-2
      statementblock-n
 
    ■ The expressionlist arguments can have any of these forms or a
      combination of them, separated by commas:
 
      expression[,expression]...
      expression TO expression
      IS relational-operator expression
 
          expression             Any numeric or string expression compatible
                                 with testexpression.
          relational-operator    One of the following relational operators:
                                   <, <=, >, >=, <>, or =.
 
Example:
    INPUT "Enter acceptable level of risk (1-5): ", Total
    SELECT CASE Total
 
        CASE IS >= 5
            PRINT "Maximum risk and potential return."
            PRINT "Choose stock investment plan."
 
        CASE 2 TO 4
            PRINT "Moderate to high risk and potential return."
            PRINT "Choose mutual fund or corporate bonds."
 
        CASE 1
            PRINT "No risk, low return."
            PRINT "Choose IRA."
 
    END SELECT
 
See Also    IF...THEN...ELSE