CheckedListBox issue

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
Back
Top