How does For...Each work under the hood for arrays?

140 Views Asked by At

A For...Each loop in VBx uses the IEnumVARIANT member of an object which supports automation with a method of DISPID_NEWENUM = -4 to iterate over its contents.

However the VBx SAFEARRAY is not an automation object deriving from IDispatch (it is not a COM object at all) and does not have an IEnumVARIANT returning method. How then does For...Each work on an array under the hood? Is there a standard method to create an IEnumVARIANT from a SAFEARRAY? Or is this interpreter special-casing?

0

There are 0 best solutions below