Metodo IndexOf

Restituisce l'indice su base zero della prima occorrenza di un valore nell'oggetto ArrayList.

Sintassi

Object.IndexOf(Element,StartIndex)

Argomenti:

  • Object: obbligatorio. Sempre il nome dell'oggetto ArrayList.

  • Element: obbligatorio. Oggetto da determinare se è incluso nell'oggetto ArrayList.

  • StartIndex: obbligatorio. Indice iniziale su base zero della ricerca.

Valore restituito

Indice su base zero della prima occorrenza di valore all'interno dell'intervallo di elementi nell'oggetto ArrayList che si estende da StartIndex all'ultimo elemento se trovato. In caso contrario, restituisce -1

Note

Nell'esempio seguente viene illustrato l'uso del metodo IndexOf.

Esempio 1

'Create ArrayList Object
Dim Obj
Set Obj = CreateObject("System.Collections.ArrayList")

'Add Elements to the end of the ArrayList Object
Dim Index
Index = Obj.Add(10)
Index = Obj.Add(40)
Index = Obj.Add(20)

'Get the Index of the Element
Index = Obj.IndexOf(40, 0)
'Output: 1
Index = Obj.IndexOf(50, 0)
'Output: -1