Contains 메소드

요소가 ArrayList 객체 내에 있는지 여부를 결정합니다.

구문

Object.Contains(Element)

인수:

  • Object: 필수. 항상 ArrayList 객체의 이름입니다.

  • Element: 필수. ArrayList 객체에서 찾을 요소입니다.

반환

ArrayList 객체 내에 요소가 있는 경우 True이고 그렇지 않으면 False입니다.

주석

다음 예에서는 Contains 메소드의 사용을 보여 줍니다.

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