Hi
now I.m a little confuse

I need to loop a CheckedListBox (only the CheckedItemCollection) . I cant
use a for each loop because I need to get the current and the next item in
the collection, so I need index (I guess..)

and I'm using this code:

For i = 0 To lstLista.CheckedIndices.Count - 1 Step 2
FunctionPrint(lstList.Items.Item(i) +" " lstList.Items.Item(i + 1)
Next

the problem is that I'm not retrieving the items I want (the Checked items)
and I cant find the instruction to get the CheckedItems using indexs

any sug

ken

Re: CheckedListBox issue by Gerald

Gerald
Tue Oct 19 19:57:00 CDT 2004

You are not actually getting the Checked Items, but the main Items at
absolute index for the count of checked items.

Replace Items with CheckItems, like so:

For i = 0 to lstList.CheckedItems.Count - 1 Step 2
FunctionPrint(lstList.CheckedItems.Item(i) & " " &
lstList.CheckedItems.Item(i+1))
Next i

or

With lstList.CheckedItems
For i = 0 to .Count -1 step 2
FunctionPrint(.Item(i) & " " & .Item(i+1))
Next i
End With

Gerald

"Ken" <Ken@discussions.microsoft.com> wrote in message
news:1FB7B8AD-DB41-4CC9-A78D-60F094DD562E@microsoft.com...
> Hi
> now I.m a little confuse
>
> I need to loop a CheckedListBox (only the CheckedItemCollection) . I cant
> use a for each loop because I need to get the current and the next item in
> the collection, so I need index (I guess..)
>
> and I'm using this code:
>
> For i = 0 To lstLista.CheckedIndices.Count - 1 Step 2
> FunctionPrint(lstList.Items.Item(i) +" " lstList.Items.Item(i +
1)
> Next
>
> the problem is that I'm not retrieving the items I want (the Checked
items)
> and I cant find the instruction to get the CheckedItems using indexs
>
> any sug
>
> ken
>