Metodo Contains

Determina se un elemento definito dall'argomento (element) è incluso nell'oggetto ArrayList.

Sintassi

Object.Contains(Element)

Argomenti:

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

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

Valore restituito

True se l'elemento viene rilevato nell'oggetto ArrayList. In caso contrario, restituisce False.

Note

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

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)

'Determines whether an element is in the ArrayList object
If Obj.Contains(40) Then 'Returns True
        'Operations based on the requirement when ArrayList contains 40 
Else
        'Operations based on the requirement when ArrayList doesn’t contains 40 
End If
'Output: True (Obj contains 40)