## XSICollection.Add

### Description

Adds a single item to a collection. Compare this method to XSICollection.AddItems, which adds one or more items at a time or XSICollection.SetAsText, which adds all items in the string list.

### C# Syntax

    XSICollection.Add( Object in_newVal );

### Scripting Syntax

    XSICollection.Add( Item );

### Parameters

Parameter | Type | Description
--- | --- | ---
Item | CollectionItem, any kind of ProjectItem or String | The new item being added. This may be a generic object (CollectionItem), a specific type of object (ProjectItem) or an Object Name (string expression).

### Examples

#### VBScript Example

    Dim oColl             ' object pointer for collection
    Dim oMember             ' object pointer for members
    Dim oNull               ' object pointer for null object
    Dim oCollItem   ' object pointer for collection item
    Dim sLightName  ' string variable for the camera name
    ' Create the stuff we will populate the collection with
    Set oNull = ActiveSceneRoot.AddNull
    checkType oNull                 ' = project item
    Set oCollItem = CreateObject( "XSI.CollectionItem" )
    oCollItem.Value = "Camera"
    checkType oCollItem                     ' = collection item
    sLightName = "light*"
    checkType sLightName                    ' = string expression
    ' Create the new collection
    Set oColl = CreateObject( "XSI.Collection" )
    ' Add each item
    oColl.Add oNull
    oColl.Add oCollItem
    oColl.Add sLightName
    ' What do we have now?
    LogMessage "----------------"
    For Each oMember In oColl
            checkType oMember
    Next
    '--------------------------------------------------
    function checkType( in_object )
            LogMessage in_object & " is a " & TypeName( in_object )
    end function
    '--------------------------------------------------
    ' Output of above script:
    'INFO : "null is a Null"
    'INFO : "Camera is a CollectionItem"
    'INFO : "light* is a String"
    'INFO : "----------------"
    'INFO : "null is a Null"
    'INFO : "Camera is a Camera"
    'INFO : "light is a Light"

### See Also

XSICollection.GetAsText XSICollection.AddItems XSICollection.Remove