RemoveAtメソッド

ArrayListオブジェクトの指定された索引の要素を削除します。

構文

Object.RemoveAt(Index)

引数:

  • Object: 必須。常にArrayListオブジェクトの名前。

  • Index: 必須。削除する要素のゼロから始まる索引。

備考

次の例では、RemoveAtメソッドの使用方法を示します。

例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)
Index = Obj.Add(30)


'Remove Element from the ArrayList Object
Index = 3
If index < Obj.Count() Then
Obj.RemoveAt(Index)
End If

'Display ArrayList Elements after Remove
For Each Element In Obj
'Operation based on requirement with the Element 
Next
'Output: Obj contains 10, 40, 20