Item Method
Gets or sets the element at the specified index from the ArrayList
Object.
Syntax
Object.Item(Index)
Arguments:
-
Object: Required. Always the name of
ArrayList
object. -
Index: Required. The zero-based index of the element to get.
Returns
Returns element which is in the Index.
Remarks
The following example illustrates the use of the Item method.
Example 1:
'Create ArrayList Object
Dim Obj
Set Obj = CreateObject("System.Collections.ArrayList")
'Add Elements to the end of ArrayList Object
Dim Index
Index = Obj.Add(10)
Index = Obj.Add(40)
Index = Obj.Add(20)
'Output: Obj contains 10, 40, 20
'Gets the Element from the ArrayList Object
Dim Element
Index = 2
If Index < Obj.Count() Then
Element = Obj.Item(Index)
'Output: 20
End If
'Set the Element in the ArrayList Object
Index = 1
If Index < Obj.Count() Then
Obj.Item(Index) = 15
End If
'Output: Obj contains 10, 15, 20