P
pietlinden
Sorry to ask a stupid question, but I checked the NG and can't get any
of the examples to work (like Steve Arbaugh's). I have two listboxes
and I'm trying to move the items from one side to the other. IOW, copy
item from lbxLeft to lbxRight, and remove the same item from lbxLeft.
The AddItem method works a champ, but no matter what I do, I can't get
the items to remove.
I thought I could do something like
Private Sub MoveSelected(ByVal lbxFrom As ListBox, ByVal lbxTo As
ListBox)
Dim varItem As Variant
Dim arrSelected(0 To 1) As Integer
Dim intIndex() As Integer '--copy selected to destination listbox
For Each varItem In lbxFrom.ItemsSelected
lbxTo.AddItem lbxFrom.ItemData(varItem)
Next varItem
'--remove from source lbxFrom (straight from the help file...)
For Each varItem In lbxFrom.ItemsSelected
lbxFrom.RemoveItem Index:=varItem
Next varItem
End Sub
For some reason, only the first item gets removed. Is this a case
where I have to iterate backwards because the collection is decreasing
in size or something?
Sorry to ask such a stupid question, but for the life of me, I can't
figure out how to get it to work. I'm sure it's the fact that the
index is changing after each loop...
So, I've checked the help file, the NG, tested a few "logical" tests...
and no joy. (Maybe this instance of clsProgrammer has a memory leak?)
Thanks for any pointers.
Pieter
of the examples to work (like Steve Arbaugh's). I have two listboxes
and I'm trying to move the items from one side to the other. IOW, copy
item from lbxLeft to lbxRight, and remove the same item from lbxLeft.
The AddItem method works a champ, but no matter what I do, I can't get
the items to remove.
I thought I could do something like
Private Sub MoveSelected(ByVal lbxFrom As ListBox, ByVal lbxTo As
ListBox)
Dim varItem As Variant
Dim arrSelected(0 To 1) As Integer
Dim intIndex() As Integer '--copy selected to destination listbox
For Each varItem In lbxFrom.ItemsSelected
lbxTo.AddItem lbxFrom.ItemData(varItem)
Next varItem
'--remove from source lbxFrom (straight from the help file...)
For Each varItem In lbxFrom.ItemsSelected
lbxFrom.RemoveItem Index:=varItem
Next varItem
End Sub
For some reason, only the first item gets removed. Is this a case
where I have to iterate backwards because the collection is decreasing
in size or something?
Sorry to ask such a stupid question, but for the life of me, I can't
figure out how to get it to work. I'm sure it's the fact that the
index is changing after each loop...
So, I've checked the help file, the NG, tested a few "logical" tests...
and no joy. (Maybe this instance of clsProgrammer has a memory leak?)
Thanks for any pointers.
Pieter