Loop to check values that are checked in a CheckedListBox
Posted on 2008-11-17
I don't even know if this is possible, but I am having problems changing a checked CheckedListBox value to something else.
For example, I have a CheckedListBox with 3 items. We will say the colors Red, Blue, and Green. However, in an outside database the same colors are represented by the numbers 1, 2, and 3. So, once the user selects one or multiple colors from the checkedlistbox, I then need to append/concat a string with the colors converted to their appropriate numbers.
For instance, if the user selected "Red" and "Green" I would need to return a string that says "'1,3'".
Dim sb as New StringBuilder
If clb.CheckedItems.ToString = "Red" Then
This returns nothing. For testing purposes, I am just outputting it in a msgbox.
If clb.SelectedItems.ToString = "Red" Then... works, but also works if the item is selected/highlighted. I need only checked items to be converted.