I was designing a form that would allow a user to select 1 or more items in one listbox and copy those items into a second listbox. As I’m trying to figure out how to get the list of select item(s) in the first listbox, I found a whole lot of suggestions, but nothing that really made sense. It seems they want you to loop through a full list looking for the ones that are selected.
I came up with the following that creates a collection of selected records. You then loop through that collection.
Dim i As ListBox.SelectedIndexCollection
i = ListBox1.SelectedIndices
For Each a In i
ListBox2.Items.Add(ListBox1.Items(a).ToString)
Next
The line in the middle of the For/Next loop is whatever you want to do with the selected records.
I hope this helps.