|Sets existing or adds a new item to the collection.
In difference to the Add
method Set method issues an error if the operation fails.
[id(10), helpstring("method Set")] HRESULT Set([in]
VARIANT VarKey,[in] VARIANT VarItem,[out,retval] VARIANT* pvarPlace);
object - Previously created VarDictionary object
key_name - expression that can be converted to a string. It becomes
the name of the new item.
item - item to set
If the key_name is a string and the name already exists in the collection
then the first item with that name will be set to the new value passed
in the item parameter. If the key_name is a string, but it is not
used in the collection - then new item will be created with the given
(by key_name) name.
If the key_name is a number - it will be treated as an item
index. If the item on that index exists it will be set to the new value
passed through the item parameter. If the index is out of the
current range/not corresponds to an existing item in the collection
operation will fail with an error.
var item = "My Item";
Set item = Server.CreateObject("ADODB.Connection")
Set method does not depend on the itemsAssignmentAllowed
property - i.e. method can be used always in difference to
the put form of the Item property.
Applies to: VarDictionary
See also: Item property,