Choose funtzioa

Argumentu-zerrenda batetik aukeratutako balioa itzultzen du.

Sintaxia:


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

Itzulera-balioa:

Variant. A value inferred from the Index parameter.

Parametroak:

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.

Choose funtzioak indizearen balioan oinarritutako adierazpenen zerrendatik hartutako balio bat itzultzen du.Indizea = 1 bada, funtzioak zerrendako lehen adierazpena itzuliko du, eta Indizea = 2 bada, bigarren adierazpena itzuliko du, eta horrela hurrenez hurren.

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.

Errore-kodeak:

5 Prozedura-dei baliogabea

13 Motak ez datoz bat

Adibidea:

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)
    AukeratuMenua = Choose(Indizea, "Formatu azkarra", "Gorde formatua", "Sistemako formatua")
End Function