Método Contains

Determina se um elemento está no Objeto ArrayList.

Sintaxe

Object.Contains(Element)

Argumentos:

  • Object: Obrigatório. Sempre o nome do objeto ArrayList.

  • Element: Obrigatório. O Elemento a ser localizado no objeto ArrayList.

Retorna

Retornará True se o Elemento for encontrado no objeto ArrayList; caso contrário, retornará False

Comentários

O exemplo a seguir ilustra o uso do método Contains.

Exemplo 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)