Home > Language Reference > Program Flow Functions > SelectCase


The Select Case...EndCase satement executes one of several groups of statements, depending on the value of an expression. 


Select Case is similar to an If block but for more complex decisions where there are several possible answers. For example if you need to process different actions depending on which weekday it is, you will use a Select Case covering the 7 possible values for the current day.


Select Case <test_expression>
        [Case <expression_1>
        [Case <expression_2>
     [Case Else


<test_expression>, numeric or string expression. If <test_expression> evaluates to one of the listed <expression_x>, the <statements> just after <expression_x> are executed.

Some possible <expression_x> are:
Case "a"
Case 1
Case a+b
Case "nom1","nom2","nom3"

If <test_expression> does not evaluate to any of the <expression_x>, the <statements> after Case Else are executed.


    Select Case day
    Case 1
    Case 2
    Case 3
    Case 4
        aday$="Wednesday "
    Case 5
        aday$="Thursday "
    Case 6
    Case 7
    Case Else

    msgbox("Hello, today is: "+aday$)