Add 메소드

ArrayList 객체의 끝에 요소를 추가합니다.

구문

Object.Add (Element)

인수:

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

  • Element: 필수. ArrayList의 끝에 추가할 요소

반환

요소가 추가된 ArrayList 인덱스

주석

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

예 1:

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

'Add Elements to the ArrayList Object
Dim Index
Index = Obj.Add(10)
'Output: 0
Index = Obj.Add(40)
'Output: 1
Index = Obj.Add(20)
'Output: 2
'Output: Obj contains 10, 40, 20

예 2:

'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("Banana")
'Output: 0
Index = Obj.Add("Apple")
'Output: 1
Index = Obj.Add("Grapes")
'Output: 2
'Output: Obj contains "Banana", "Apple", "Grapes"