6.1.3.1.2.1 Add
Function Declaration
-
Sub Add(Item As Variant, Optional Key As Variant, Optional Before As Variant, Optional After As Variant)
Parameter |
Description |
---|---|
Item |
An expression of any type that specifies the member to add to the collection. |
Key |
A unique String expression that specifies a key string that can be used, instead of a positional index, to access a member of the collection. |
Before |
An expression that specifies a relative position in the collection. The member to be added is placed in the collection before the member identified by the before argument. If a numeric expression, before MUST be a number from 1 to the value of the collection's Count property. If a String expression, before MUST correspond to the key specified when the member being referred to was added to the collection. Either a Before position or an After position can be specified, but not both. |
After |
An expression that specifies a relative position in the collection. The member to be added is placed in the collection after the member identified by the After argument. If numeric, After MUST be a number from 1 to the value of the collection's Count property. If a String, After MUST correspond to the Key specified when the member referred to was added to the collection. Either a Before position or an After position can be specified, but not both. |
Runtime Semantics.
§ Adds a member to a Collection object.
§ Whether the before or after argument is a string expression or numeric expression, it MUST refer to an existing member of the collection, or an error occurs.
§ An error also occurs if a specified Key duplicates the key for an existing member of the collection.
§ An implementation can define a maximum number of elements that a Collection object can contain.