Implementing the IEnumVARIANT Interface

Automation defines the IEnumVARIANT interface to provide a standard way for ActiveX clients to iterate over collection objects. Every collection object must expose a read-only property named _NewEnum to let ActiveX clients know that the object supports iteration. The _NewEnum property returns an enumerator object that supports IEnumVARIANT.

The IEnumVARIANT interface provides a way to iterate through the items contained by a collection object. This interface is supported by an enumerator object that is returned by the _NewEnum property of the collection object, as in the following figure.


The IEnumVARIANT interface defines these member functions:

  • Next — Retrieves one or more elements in a collection, starting with the current element.

  • Skip — Skips over one or more elements in a collection.

  • Reset — Resets the current element to the first element in the collection.

  • Clone — Copies the current state of the enumeration so you can return to the current element after using Skip or Reset.