From: iccsi on
I tried to process something for 2 list box and need to iterate 2 of
them and one iterates selected items one iterates all list

For i = 1 To lst1.ListCount
For Each VarItem In lst2.ItemsSelected
' my loop is here
Next VarItem
Next i

It seems that every VarItem increase the i increase as well.
I want VarItem to be inner loop which should be finish all seleted
item and go to next i.

Where is wrong to use above code?

Any information is great appreciated,
From: Tom van Stiphout on
On Fri, 4 Jun 2010 07:49:08 -0700 (PDT), iccsi <inungh(a)gmail.com>
wrote:

No, this is indeed a nested loop and i is not incremented until we
loop over all items of the inner loop.
Set a breakpoint at the top of the code and step through it to see for
yourself.

-Tom.
Microsoft Access MVP


>I tried to process something for 2 list box and need to iterate 2 of
>them and one iterates selected items one iterates all list
>
> For i = 1 To lst1.ListCount
> For Each VarItem In lst2.ItemsSelected
> ' my loop is here
> Next VarItem
> Next i
>
>It seems that every VarItem increase the i increase as well.
>I want VarItem to be inner loop which should be finish all seleted
>item and go to next i.
>
>Where is wrong to use above code?
>
>Any information is great appreciated,