Items - Add / Remove

Members can be added before or after an existing member based on both the index number or a key value
All collections are 1 based.


Adding

Collection.Add (item [,key] [,before] [,after])
item - the item you want to add to the collection
key - a unique string that can be used instead of using the positional index
before - the relative position index (or key string) of the element to have in front of it.
after - the relative position index (or key string) of the element to have behind it.


Adding Before

This adds "Wed" before "Mon"


Adding After

This adds "Wed" after "Mon"


Adding Using a Loop

Do not add items like this


Adding Duplicates

The items in a collection do not have to be unique.

When a key is not supplied the "key" field is left blank.
If a key has not been provided the only way to access the items is by their position.

You cannot identify or retrieve these items by key, because they don't have one.
If you do use keys, they must be unique.



Removing

Collection.Remove (index)
index - the relative position index (or key string) of the element you want to remove


Remove All

A collection does not have a RemoveAll
Set myCollection = Nothing
Multiple deletion using the index number should be done in descending order because the collection is reindexed every time.


© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext