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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top