why won't this remove the items from list2.
Private Sub Command1_Click()
Dim i As Integer
For i = 0 To List1.ListCount - 1
list2.RemoveItem i
Next i
End Sub
Printable View
why won't this remove the items from list2.
Private Sub Command1_Click()
Dim i As Integer
For i = 0 To List1.ListCount - 1
list2.RemoveItem i
Next i
End Sub
Maybe because List1 has more items than List2. Is this the case with you?
No Megatron. Even if List1.RemoveItem i is used, the same error will occur. I had this problem myself.
It is because List2.ListCount decreases when the list items are removed. List2.ListCount is less than i at one point.
Use this code to solve your problem.
[Edited by shafee on 11-17-2000 at 08:14 PM]Code:Private Sub Command1_Click()
Dim i As Integer
For i = 0 To List1.ListCount - 1
List2.RemoveItem 1
Next i
End Sub
'try this
Private Sub Command1_Click()
Dim i As Integer
Form1.Show
For i = 0 To List1.ListCount - 1
List2.RemoveItem 0
Next i
End Sub