vbscript - How do I make my custom class compatible with For Each? -
is possible make custom container class implemented purely in vbscript (no com objects) work each statement? if so, methods must expose?
in short, no
why? create enumerable collection class
class ctest .... end class dim otest, melement set otest = new ctest .... each melement in otest .... next the class must follow rules. need class expose
a public readonly property called
counta public default method called
itema public readonly property called
_newenum, should return an
iunknowninterface object implementsienumvariantinterface , must have hidden attribute , dispatch id of -4
and list or requirements, vbscript not include way indicate dispatch id or hidden attribute of property.
so, can not done
the way enumerate on elements stored in container class have property (or method) returns
an object supports indicated requirements, same object used hold elements (fast, expose information)
an array (in vbscript arrays can enumerated) holding references each of elements in container (slow if array needs generated on call, not return non required information)
Comments
Post a Comment