qb45advr.hlp (Topic list)
SELECT Statement Details
  QuickSCREEN      Details      Example      Contents      Index
──────────────────────────────────────────────────────────────────────────────
SELECT Statement Details
 
Syntax
  SELECT CASE testexpression
  CASE expressionlist1
    [statementblock-1]
  [CASE expressionlist2
    [statementblock-2]] ...
 
  [CASE ELSE
    [statementblock-n]]
  END SELECT
 
  Argument            Description
  testexpression      Any numeric or string expression.
 
  statementblock-1,   The elements statementblock-1 to
  statementblock-2,   statementblock-n consist of any number of
  statementblock-n    statements on one or more lines.
 
  expressionlist1,    These elements can have any of the three
  expressionlist2     following forms:
 
                        expression[,expression...]
                        expression TO expression
                        IS relational-operator expression
 
The following list describes the parts of an expressionlist:
 
  Argument              Description
  expression            Any numeric or string expression. The type of
                        the expression must match the type of the
                        testexpression.
 
  relational-operator   Any of the following operators:
 
                          Symbol    Meaning
                          <         Less than
                          <=        Less than or equal to
                          >         Greater than
                          >=        Greater than or equal to
                          <>        Not equal
                          =         Equal
 
If the testexpression matches the expressionlist associated with a
CASE clause, then the statement block following that CASE clause is
executed up to the next CASE clause or, for the last one, up to END
SELECT.  Control then passes to the statement following END SELECT.
 
If you use the TO keyword to indicate a range of values, the smaller
value must appear first. For example, the statements associated with the
line CASE -1 TO -5 are not executed if the testexpresssion is -4.  The
line should be written as CASE -5 TO -1.
 
You may use a relational operator only if the IS keyword appears. If
CASE ELSE is used, its associated statements are executed only if the
testexpression does not match any of the other CASE selections. It is
a good idea to have a CASE ELSE statement in your SELECT CASE block to
handle unforeseen testexpression values.
 
When there is no CASE ELSE statement, and no expression listed in the
CASE clauses matches testexpression, program execution continues
normally. No error occurs.
 
You may use multiple expressions or ranges in each CASE clause. For
example, the following line is valid:
 
  CASE 1 TO 4, 7 TO 9, 11, 13, IS > MaxNumber%
 
You may also specify ranges and multiple expressions for strings:
 
  CASE "everything", "nuts" TO "soup", TestItem$
 
CASE matches strings that are exactly equal to everything, the current
value of TestItem$, or that fall between nuts and soup in alphabetical
order.
 
Strings are evaluated according to the ASCII values of their characters.
Lower-case letters have larger ASCII values than upper-case, therefore
 
  nuts > Nuts > NUTS
 
If an expression appears in more than one CASE clause, only the statements
associated with the first appearance of the expression are executed.
 
SELECT CASE statements may be nested. Each SELECT CASE statement must have
a matching END SELECT statement.