Contains Method
Determines whether an element is in the ArrayList
Object.
Syntax
Object.Contains(Element)
Arguments:
-
Object: Required. Always the name of
ArrayList
object. -
Element: Required. The Element to locate in the
ArrayList
object.
Returns
True if Element is found in the ArrayList
object otherwise False
Remarks
The following example illustrates the use of the Contains
method.
Example 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)