I used your great CustomCollection
and EnumHelper
from your post https://stackoverflow.com/a/65736562/7658533
Then I implemented two test procedures, TestOk
and TestOk
, both using a function GetCustomCollection
to retrieve a CustomCollection
instance.
The first procedure TestOk
stores the instance in a local variable first, the second TestNotOk
uses the instance inline from the functions result.
As you can see, TestNotOk
does not iterate any value of the resulting instance.
Do you have a clue how CustomCollection
and/or EnumHelper
can be reworked to get TestNotOk
running properly too?
Public Sub TestOk()
Dim xCustomCollection As CustomCollection
Set xCustomCollection = GetCustomCollection()
Dim xItem As Variant
For Each xItem In xCustomCollection.NewEnum
Debug.Print xItem
Next xItem
End Sub
Public Sub TestNotOk()
Dim xItem As Variant
For Each xItem In GetCustomCollection().NewEnum
Debug.Print xItem
Next xItem
End Sub
Private Function GetCustomCollection() As CustomCollection
Set GetCustomCollection = New CustomCollection
GetCustomCollection.Add 1
GetCustomCollection.Add 2
End Function