Getting a Specific Object from a List

You must get a specific object from a list before you can use it.

Visual Basic

Because the Item method is the default method of a list, you can get a specific object in a list by specifying one of the following:

in parentheses after the list object. You can also use the Item method explicitly. Use the following syntax:

Parent.ListObjects( {strName | lOrdinal} )

Or

Parent.ListObjects.Item( {strName | lOrdinal} )

C++

When you have a pointer to a list object, you can get a pointer to a specific object in that list by using the GetItemByOrd or GetItemByName function.

To use GetItemByOrd, pass an ordinal value (0-based) and the address of a list object variable (use the address of & operator) of the appropriate type (LPSQLOLEOBJECTLIST) to the function. It will write the specific object pointer to your object variable. Use the following syntax:

pObjectList->GetItemByOrd ( lOrdinal, &pObject );

To use GetItemByName, pass the name of the specific object and the address of a list variable of the appropriate type (LPSQLOLEOBJECTLIST) to the function. It will write the specific object pointer to your object variable. Use the following syntax:

pObjectList->GetItemByName ( strName, &pObject );