About a year ago a wrote a program and used the code below. I need it again for a new program but looking at it now that I kind of know what’s going on, the code just doesn’t make sense to me. I don’t understand how it’s working. It is working though, been used hundreds of times in the last year so it is working, I just don’t see how.
Basically I fill an array and then dump that array into a ListBox. From there I run the code below to get rid of any duplicated data now in the ListBox.
For i = 0 To List13.ListCount - 1
For x = 0 To List13.ListCount - 1
If Me.List13.ItemData(i) = Me.List13.ItemData(x) And x <> i Then
List13.RemoveItem i
End If
Next x
Next I
Works great and gets rid of all the duplicates.
But my issue is trying to understand why, if “x” and “I” are always = to each other, is it not getting rid of every line of data?
Is it the "And x <> i"? I don't really understand what that is doing.
Basically I fill an array and then dump that array into a ListBox. From there I run the code below to get rid of any duplicated data now in the ListBox.
For i = 0 To List13.ListCount - 1
For x = 0 To List13.ListCount - 1
If Me.List13.ItemData(i) = Me.List13.ItemData(x) And x <> i Then
List13.RemoveItem i
End If
Next x
Next I
Works great and gets rid of all the duplicates.
But my issue is trying to understand why, if “x” and “I” are always = to each other, is it not getting rid of every line of data?
Is it the "And x <> i"? I don't really understand what that is doing.