Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does ASP Classic FOR EACH loop work

I would like to now how the ASP Classic/VB6 FOR EACH loop works. I know with .NET IEnumberable/IEnumerator are involved, but how does VB6/ASP Classic do it?

Thanks!

like image 208
Ian McShane Avatar asked Jun 09 '26 05:06

Ian McShane


1 Answers

It does it in a very similar way. A class that supports foreach has a method that has the DispID of -4 which returns an enumerator object similar to an implementation of IEnumerator.

If you intend to implement this in VB6 then whilst it is possible you will have to be prepared to jump through prohibitively complicated hoops, especially since such insanely complicated stuff is now well past its sell by date. The COM equivalent to IEnumerator is stole.IEnumVARIANT, one characteristic that makes it incompatible with a simple implementation in VB6 is that its Next method uses S_FALSE HResult.

If you really, really want to do this then get this book: Advanced Visual Basic 6 if you can. Warning from a typical VB6 developers point of view the term "Advanced" doesn't really do it justice. "Insanely deep VB6" would be a better description.

like image 95
AnthonyWJones Avatar answered Jun 10 '26 18:06

AnthonyWJones



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!