Hello,
Looks like you are using a CheckedListBox not a ListBox. You can process items via LINQ, get only checked items text and do what you want. We can get the text and ordinal position too.
The code below will get only checked items then add them to normal ListBox. In the for/next you would do your delete and on failure do the Add to the ListBox. Please excuse the names I used for the procedure and second parameter my brain is out there right
now.
<System.Runtime.CompilerServices.Extension()> _
Public Sub WhatEver(ByVal sender As CheckedListBox, ByVal Other As ListBox)
Dim Items =
(
From Item In sender.Items.Cast(Of String)() _
.Where(Function(xItem, Index) sender.GetItemChecked(Index)) _
.Select(Function(a, b) New With {.Index = b, .Text = a})
).ToList
For Each item In Items
Other.Items.Add(item.Text)
Next
End Sub
To try this out, download
this project and add a ListBox and button. Add this code to the button
clbOptions.WhatEver(ListBox1)
Place the first code block in the module ExtensionMethods.vb and this works for you add the code to your project.
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.