Utility components Add
Adds a new item to the collection.


variable = object.Add(key_name,item)

IDL definition:

[id(1), helpstring("Adds item to the collection")] 
    HRESULT Add([in] VARIANT varKey,[in] VARIANT varItem,[out,retval] VARIANT* pvarPlace);


object - Previously created VarDictionary object

variable - variable that will receive the index of the new item in the collection (VT_I4 type)

key_name - expression that can be converted to a string. It becomes the name of the new item.

If the key_name already exists in the collection operation fails and 0 is returned unless the allowDuplicateNames.property is not set to true. key_name can be empty if the allowUnnamedValues is set to true. key_name is assumed to be empty if it is an empty string or another value not convertible to string. 


var item = "My Item";
var place = vardict.Add("Item 3",item);

Dim item,place
Set item = Server.CreateObject("ADODB.Connection")
place = vardict.Add("Item 3",item)


In C++ projects HRESULT returned can be used to determine success - S_OK is returned on success and S_FALSE on failure (if the key_name already exists in the collection).

Applies to: VarDictionary

See also: Item property, allowDuplicateNames, allowUnnamedValues


newObjects Copyright 2001-2005 newObjects [ ]