Choose Function

рддрд░реНрдХрдХреЛ рд╕реВрдЪреАрдмрд╛рдЯ рдЪрдпрди рднрдПрдХреЛ рдорд╛рди рдлрд░реНрдХрд╛рдЙрдБрдЫ ред

Syntax:


  Choose (Index As Integer, Expression1[, Expression2, ... [, Expression_n]]) As Variant

Return value:

Variant. A value inferred from the Index parameter.

Parameters:

Index: Any numeric expression rounded to a whole number. Index accepts integer values starting at 1 that specify which of the possible choices to return.

Expression1, Expression2, тАж, Expression_n: Expressions representing each of the possible choices.

The Choose function returns a value from the list of expressions based on the index value. If Index = 1, the function returns the first expression in the list, if Index = 2, it returns the second expression, and so on.

If the index value is less than 1 or greater than the number of expressions listed, the function returns a Null value.

Error #5 occurs when parameters are omitted. Error #13 occurs if Index equals Null.

рддреНрд░реБрдЯрд┐ рд╕рдЩреНрдХреЗрддрд╣рд░реВ

5 рдЕрд╡реИрдз рдХрд╛рд░реНрдп-рд╡рд┐рдзрд┐ рдХрд▓

13 рдкреНрд░рдХрд╛рд░ рдЕрд╢реБрджреНрдз рдЬреЛрдбрд╛

Example:

The following example uses the or Choose function to select a string from several strings that form a menu:


Sub ExampleChoose
    Print ChooseMenu(2) ' "Save Format"
    MsgBox Choose(index :=  -5, 9, "Basic", PI) ' Null
    MsgBox Choose(index := 3.14, 9, "Basic", PI) ' PI
End Sub
 
Function ChooseMenu(Index As Integer)
    рдореЗрдиреБ рд░реЛрдЬреНрдиреБрд╣реЛрд╕реН =рд░реЛрдЬреНрдиреБрд╣реЛрд╕реН(рдЕрдиреБрдХреНрд░рдордгрд┐рдХрд╛, "рджреНрд░реБрдд рдврд╛рдБрдЪрд╛", "рдмрдЪрдд рдврд╛рдБрдЪрд╛", "рд╢реИрд▓реА рдврд╛рдБрдЪрд╛")
End Function