TrimToSize-Methode

Legt die Kapazität auf die tatsächliche Anzahl an Elementen im ArrayList-Objekt fest.

Syntax

Object.TrimToSize()

Argumente: Object: Erforderlich. Immer der Name eines ArrayList-Objekts.

Anmerkungen

Das folgende Beispiel veranschaulicht die Verwendung der TrimToSize-Methode.

Beispiel 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