將元素新增至 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"