IEnumerator: Current (get) |
Gets the current element in the collection.
Public Property Get Current ( ) As Variant
After an enumerator is created or after the Reset method is called, the MoveNext method must be called to advance the enumerator to the first element of the collection before reading the value of the Current property; otherwise, Current is undefined.
Current also throws an exception if the last call to MoveNext returned False, which indicates the end of the collection.
Current does not move the position of the enumerator, and consecutive calls to Current return the same object until either MoveNext or Reset is called.
Read Only.
The following example shows an implementation of the IEnumerator interface.
This example is part of a larger complete example for IEnumerable.
Option Explicit Implements IEnumerator Private mBase As EnumeratorBase Private mContainer As Container ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Constructors ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Public Sub Init(ByVal Container As Container) Set mBase = NewEnumeratorBase(0, Container.Count) Set mContainer = Container End Sub ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' IEnumerator ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Property Get IEnumerator_Current() As Variant MoveVariant IEnumerator_Current, mContainer.Item(mBase.Index) End Property Private Function IEnumerator_MoveNext() As Boolean IEnumerator_MoveNext = mBase.MoveNext End Function Private Sub IEnumerator_Reset() mBase.Reset End Sub