K
K
I got code below which basically removes duplicates from Listbox2. It
works but the only problem is that I get error message saying "Run-
time error 381: Could not get the List property. Invalid property
array index" and when I click on "Debug" button it highlites the line
"If Me.ListBox2.List(i) = Me.ListBox2.List(x) Then". Please can any
friend help me on this that how can i correct this error.
******************code****************************
Private Sub CommandButton4_Click()
Dim i As Integer, x As Integer
For i = 0 To Me.ListBox2.ListCount - 1
For x = 0 To Me.ListBox2.ListCount - 1
If i <> x Then
If Me.ListBox2.List(i) = Me.ListBox2.List(x) Then
Me.ListBox2.RemoveItem (x)
Exit For
End If
End If
Next x
Next i
End Sub
works but the only problem is that I get error message saying "Run-
time error 381: Could not get the List property. Invalid property
array index" and when I click on "Debug" button it highlites the line
"If Me.ListBox2.List(i) = Me.ListBox2.List(x) Then". Please can any
friend help me on this that how can i correct this error.
******************code****************************
Private Sub CommandButton4_Click()
Dim i As Integer, x As Integer
For i = 0 To Me.ListBox2.ListCount - 1
For x = 0 To Me.ListBox2.ListCount - 1
If i <> x Then
If Me.ListBox2.List(i) = Me.ListBox2.List(x) Then
Me.ListBox2.RemoveItem (x)
Exit For
End If
End If
Next x
Next i
End Sub