取得或設定 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