Private Sub Class_Initialize size = 0 ReDim items(1) End Sub
Private Sub Class_Terminate items = null End Sub
Public Function Add(ByVal value) If (size = Ubound(items)) Then EnsureCapacity((size + 1))
items(size) = value size = size + 1 Add = size End Function
Public Property Get Item(index) Item = items(index) End Property
Public Property Let Item(index, vObject) items(index) = vObject End Property
Property Get Count Count = size End Property
Public Property Get Capacity() Capacity = Ubound(items) End Property
Public Property Let Capacity(value) If (value <> Ubound(items)) Then If (value < size) Then Err.Rise 6
If (value > 0) Then ReDim Preserve items(value) Else ReDim Preserve items(3) End If End If End Property
Private Sub EnsureCapacity(ByVal min) If (Ubound(items) < min) Then Dim num1 : num1 = IIf((Ubound(items) = 0), 4, (Ubound(items) * 2)) If (num1 < min) Then num1 = min Capacity = num1