Skip to content

Select case end

Description

This statement should be used to open a comparison of ONE variable against a number of constant values. The END statement is used to terminate the statement.

Syntax

Select Case <Expression>
    Case <Constant>
        <Statements>
    Break
    Case <Constant> [,<Constant> [, <Constant>]]
        <Statements>
    Break
End

Sample

Dim iVal
Let iVal = 0

Select Case iVal
    Case -2, -1, 0, 1, 2
        Select Case iVal
            Case 1
                Return "ONE"
            Break
            Case 2
                Return "TWO"
            Break
        End
        Return "ZERO or below ZERO"
    Break
    Case 3, 4, 5, 6
        Return "between THREE and SIX inclusive"
    Break
    Case 8, 9, 10
        Return "Between EIGHT and TEN inclusive"
    Break
    Case Else
        Return "something else"
    Break
End

Notes

  • The constant values should only appear once; if they appear multiple times, the first comparison wins.