-
I have 2 List Boxes. I am moving a few items from List1 to List2. However, if I try moving these items back into List1 an empty item at the top of List 1 appears. How can I get rid of this invisible item. The code is as follows:
Private Sub cmdAdd_Click()
Dim i As Integer
List2.AddItem List1.Text
i = List1.ListIndex
If i >= 0 Then List1.RemoveItem i
List1.ListIndex = 0
End Sub
Private Sub cmdRemove_Click()
Dim j
List1.AddItem (List2.Text)
j = List2.ListIndex
If j >= 0 Then List2.RemoveItem j
End sub
Any ideas ?
-
Comment the last line of sub cmdadd_click
-
Test it:
-------------
Private Sub cmdAdd_Click()
Dim i As Integer
i = List1.ListIndex
If i < 0 Then Exit Sub
List2.AddItem List1.Text
List1.RemoveItem i
If List1.ListCount = 0 Then Exit Sub
If i = 0 Then i = 0 Else i = i - 1
List1.ListIndex = i
List1.SetFocus
End Sub
Private Sub cmdRemove_Click()
Dim i
If i < 0 Then Exit Sub
List1.AddItem List2.Text
List2.RemoveItem i
If List2.ListCount = 0 Then Exit Sub
If i = 0 Then i = 0 Else i = i - 1
List2.ListIndex = i
List2.SetFocus
End Sub
------------------
smalig
[email protected]
smalig.tripod.com