ArrayListオブジェクトの実際の要素数に容量を設定します。
構文
Object.TrimToSize()
引数 - Object: 必須。常にArrayListオブジェクトの名前。
備考
次の例では、TrimToSizeメソッドの使用方法を示します。
例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)
'Sets the capacity to the actual number of elements in the ArrayList object
Obj.TrimToSize ()
'Output: Internally ArrayList Capacity changed to the actual number of elements in the ArrayList object