From Xojo Documentation
Executes one of several groups of statements, depending on the value of an expression.
Select Case testExpression
[Case [Is] expression-n [statements-n]
Else or Case Else
|testExpression||Any expression that evaluates to a value. The expression can be of any data type or an object.|
|Any expression or list of expressions. You can use a function that evaluates to the data type of testExpression. The expression can be a single value, a comma-delimited list of values, a function that returns a value, a range of values specified with the "To" keyword, an expression that uses the Is keyword to do an equality or inequality test, or an expression that uses IsA to determine the data type of an object.|
|statements-n||Statements to be executed if expression-n is true.|
|elseStatements||Statements to be executed if no expressions are True.|
The Select Case statement is useful when there are several possible conditions that must be checked. Unlike an If statement, the Select Case statement will exit as soon as it finds a matching Case expression and executes any statements that follow the Case expression up to the next Case expression. If there are no Case expressions that match, the elseStatements are executed.
The expression Case Else can be used as a synonym for Else.
The Case statement can accept several types of expressions. The expression can be a single value, a comma-delimited list of values, a function that returns a value, a range of values specified with the "To" keyword, an expression that uses the Is keyword to do an equality or inequality test, or an expression that uses IsA to determine whether an object is a member of a particular class. You can combine types of expressions, separating them by commas.
Here are some examples:
Case 2 To 5 // range of values using To
Case 2 To 5, 7, 9, 11 // Both separate values and range
Case myFunction(x) // a Function
Case Is >= 42 // greater than/equal to operator
Case Is < 19 // less than operator
Case IsA PushButton // tests whether an object is a pushbutton
You can declare local variables using the Dim statement inside a Case statement. Such variables will be local to the Select Case statement and will, therefore, be out of scope after the End Select statement executes. For example:
Dim day As String
day = "Tuesday"
MsgBox("It's not Tuesday!")
MsgBox(day) // day is out of scope here
The variable "day" should be declared prior to the Select...Case statement so that it is available after the End Select statement executes.
This example uses the Select Case statement to determine which day of the week the user has entered into a TextField and displays a message based on that information.
Dim msg As String
dayNumber = Val(TextField1.Text)
Select Case dayNumber
msg = "It's Monday"
msg = "It's Tuesday"
msg = "It's Wednesday"
msg = "It's Thursday"
msg = "It's Friday"
msg = "It's the weekend."
Dim b As MessageDialogButton // for handling the result
d.Icon = MessageDialog.GraphicCaution // display warning icon
d.ActionButton.Caption = "Save"
d.CancelButton.Visible = True // show the Cancel button
d.CancelButton.Cancel = True // esc key works for Cancel
d.AlternateActionButton.Visible = True // show the "Don't Save" button
d.Message = "Save changes before closing?"
d.Explanation = "If you don't save your changes, you will lose "_
+ "all that important work you did since your last coffee break."
b = d.ShowModal // display the dialog
Select Case b // b is a MessageDialogButton
Case d.ActionButton // determine which button was pressed.
// user pressed Save
//user pressed Don't Save
// user pressed Cancel