Add Method
Adds an element to the end of the ArrayList Object.
Syntax
Object.Add (Element)
Arguments:
-
Object: Required. Always the name of
ArrayListobject. -
Element: Required. The Element to be added to the end of the
ArrayList
Returns
The ArrayList index at which the Element has been added
Remarks
The following example illustrates the use of the Add method.
Example 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
Example 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"