Share via


IContentList::Search Method

Use this method to create a RowCollection object that allows access to each item in the ContentList object that matches the specified criterion.

HRESULT IContentList::Search(
  VARIANT vCol,
  VARIANT vSearchCriteria,
  IRowCollection** ppIRowCollection
);
Function Search(
    vCol As Variant,
    vSearchCriteria As Variant
) As IRowCollection

Parameters

  • vCol
    [C++]

    [in] A VARIANT that identifies the column to search. The column is identified by either a number representing a column position, starting at zero (0), or a string containing a column name.

    [Visual Basic]

    A Variant that identifies the column to search. The column is identified by either a number representing a column position, starting at zero (0), or a string containing a column name.

  • vSearchCriteria
    [C++]

    [in] A VARIANT that contains the filter criterion. The criterion is usually a BSTR, an integer, or a SAFEARRAY of VARIANTS containing BSTRs or integers. The Search method will attempt to coerce other types to the type of the column being searched.

    [Visual Basic]

    A Variant that contains the filter criterion. The criterion is usually a String, an array of Strings, or an Integer. An attempt will be made to coerce other types to the type of the column being searched.

  • ppIRowCollection
    [C++]

    [out,retval] A pointer to an address to receive an IRowCollection interface pointer for a new RowCollection object that allows access to the rows that match the search criteria.

Return Value

[C++]

This method returns an HRESULT indicating whether it completed successfully. See the Error Values section for more details.

[Visual Basic]

If this method completes successfully, it returns a reference to a new RowCollection object that contains one row for each matching item.

Error Values

[C++]

This method returns S_OK (0x00000000) to indicate success and standard COM HRESULT error values to indicate failure. For more information about standard COM errors, see Standard COM Errors. Additional information may be available using the global Err object, which can be accessed using the API function GetErrorInfo. In particular, the GetDescription method of the IErrorInfo interface may return a text description of the error.

[Visual Basic]

This method sets the Number property of the global Err object to S_OK (&H00000000) to indicate success and to standard COM error values to indicate failure. For more information about standard COM errors, see Standard COM Errors. Additional information may be available using the global Err object. In particular, the Description property may contain a text description of the error.

The following standard COM error value has a particular meaning in the context of this method.

  • S_FALSE
    No rows in the ContentList object matched the filter criteria. As a result, the returned RowCollection is empty.

Remarks

Columns must be shared (not private) and read-only in order to be indexed and searched. Columns must also be of type string, integer (long or short), or variant array to be searchable. The search criteria may be any variant type that can be coerced to the type of the column being searched.

When the search criteria is an array of variants, the set of rows returned contains all rows that match any of the search criteria array elements. It is a union of the matches.

This property is functionally identical to the one of the same name in the ContentListFactory object.

Example

'myCol is a RowCollection object.
Set myCol = myContentList.Search(10, "CarAds")

See Also

Other Resources

ContentList Object