I have two unbound list boxes. The first one is populated with File names from a given folder. I want to be able to push them to the other list box, using the multi-select, selected property. Then, remove the selected items from the first listbox. The .selected only seems to work on the last value selected. The others are highlighted, but do not come in as selected.
I get all of the correct items to the next list box, but it ends up deleting the wrong ones.
Code:
Public Sub MoveListBoxSelections(ActiveCtrl As ListBox, PassiveCtrl As ListBox)
Dim i As Integer
Dim varItem As Variant
Dim ListCount As Integer
ListCount = ActiveCtrl.ListCount
For i = ListCount - 1 To 0 Step -1
If ActiveCtrl.Selected(i) Then
PassiveCtrl.AddItem (ActiveCtrl.ItemData(i))
ActiveCtrl.RemoveItem (i)
End If
Next i
I get all of the correct items to the next list box, but it ends up deleting the wrong ones.