Choose 函数
返回参数列表中选定的值。
语法:
Choose (Index, Selection1[, Selection2, ...[,Selection_n]])
参数:
Index:用于指定返回值的数字表达式。
Selection1:含有一个可能选项的任意表达式。
Choose 函数将根据 Index 值从表达式列表中返回一个值。如果 Index = 1,函数将返回列表中的第一个表达式;如果 Index i= 2,则返回第二个表达式,以此类推。
如果 Index 值小于 1 或者大于列出的表达式数量,函数将返回“空”值。
下面示例中的 Choose 函数将从构成菜单的几个字符串中选择一个字符串:
示例:
Sub ExampleChoose
Dim sReturn As String
sReturn = ChooseMenu(2)
Print sReturn
End Sub
Function ChooseMenu(Index As Integer)
ChooseMenu = Choose(Index, "Quick Format", "Save Format", "System Format")
End Function