Metodo LastIndexOf

Restituisce l'indice su base zero dell'ultima occorrenza di un valore nell'oggetto ArrayList.

Sintassi

Object.LastIndexOf(Element)

Argomenti:

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

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

Valore restituito

Indice su base zero dell'ultima occorrenza del valore all'interno dell'intero oggetto ArrayList, se viene rilevato. In caso contrario, restituisce -1.

Note

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

Esempio 1

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

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

'Get Last Index of the Element
Index = Obj.LastIndexOf(40)
'Output: 3
Index = Obj.LastIndexOf(50) 
'Output: -1