Método TrimToSize

Define a capacidade para o número real de elementos no objeto ArrayList.

Sintaxe

Object.TrimToSize()

Argumentos - Object: Obrigatório. Sempre o nome do objeto ArrayList.

Comentários

O exemplo a seguir ilustra o uso do método TrimToSize.

Exemplo 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