Tag Archives: collection

To reverse a collection

Environment: VBA
Function: To reverse a collection

Dim Reversed As Collection
Set Reversed = New Collection ‘DONT FORGET THIS
For i = 1 To Collection.Count ‘Collection Starts with 1!
Reversed.Add(Collection.Item(Collection.Count – i + 1))


Start Indices of VBA Collection and ArcGIS IPointCollection

Note that VBA Collection starts with an annoying 1, while IpointCollection starts with 0. phew.

VBA Collection: substitute an item at position j

WHAT! VBA collection does not allow you to alter an item!!!
And its Array object is weird. I still have not found out how to use it yet.

To substitute an item in a VBA collection, make this call:

pFeat.Add Item:=”Item”, Before:=j
pFeat.Remove j + 1