You forget one important factor also, FOR EACH takes alot of memory
(depending on your array size)
So, as stated, FOR NEXT is in most cases alot better.
Regards
Fredrik Melin
"Rob Panosh" <rob_!!!NO!!!SPAM!!!_(E-Mail Removed)> wrote in
message news:(E-Mail Removed)...
> Fergus,
>
> Thanks for you post.
>
> So if I have routines traversing lots of items in collections then the
code
> FOR NEXT (below) would be better than using FOR EACH? So I am guessing
the
> rule of thumb is to use FOR NEXT over FOR EACH for heavliy used routines.
>
> Thanks,
> Rob Panosh
>
> Dim oItem AS Something
> For i = 0 to al.count-1
> oItem = al.Item(i)
> ' Do some processing
> ...
> ...
> ...
> next
>
> For Each oItem As Something In al
> 'Do some processing
> ...
> ...
> ...
> Next
>
>
>
> "Fergus Cooney" <filter-(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi Rob,
> >
> > For Each uses an enumerator behind the scenes so, as expected, on
the
> > tests that I did, they came out even (to the 3rd dec place). The
> difference is
> > almost certainly due to timng inaccuracies.
> >
> > On the other hand - using For I = 0 To al.Count - 1 was three times
> > faster!
> >
> > Regards,
> > Fergus
> >
> >
> >
>
>
|