Choose (function)

Syntax Choose(index,expression1,expression2,...,expression13)
Description Returns the expression at the specified index position.
Comments The index parameter specifies which expression is to be returned. If index is 1, then expression1 is returned; if index is 2, then expression2 is returned, and so on. If index is less than 1 or greater than the number of supplied expressions, then Null is returned. The Choose function returns the expression without converting its type. Each expression is evaluated before returning the selected one.
Example This example assigns a variable of indeterminate type to a.
Sub Main()
  Dim a As Variant
  Dim c As Integer
  c% = 2
  a = Choose(c%,"Hello, world",#1/1/94#,5.5,False)
  MsgBox "Item " & c% & " is '" & a & "'" 'Displays the date passed as parameter 2.
End Sub
See Also Switch (function); IIf (function); If...Then...Else (statement); Select...Case (statement).