ArrayListオブジェクトから、指定された索引の要素を取得または設定します。
構文
Object.Item(Index)
引数:
Object: 必須。常にArrayListオブジェクトの名前。
Index: 必須。取得する要素のゼロから始まる索引。
戻り値
索引にある要素を戻します。
備考
次の例は、Itemメソッドの使用方法を示しています。
例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