There is some issues with your code that may have no relation to the double entries of you CLV, they are issues nontheless. Let's look at just one fragment (this is repeated several times in your code with some slight changes):
For i = 0 To Persons.Size - 1
Dim usr As Person
usr = Persons.Get(i)
If usr.userid = namenum(2) Then
usr.sortnumber = 1
usrlist.RemoveAt(i)
Exit
End If
Next
Issue#1:
It's amazing this code has not thrown an error for you yet. Every time you remove an item from a list, the size changes and therefore the upper index becomes one less.
Example code that shows the issue (it will throw an error)
Dim l As List
l.Initialize
For x = 1 To 10
l.Add(x)
Next
l.RemoveAt(8)
l.RemoveAt(9)
and error displayed:
java.lang.IndexOutOfBoundsException: Index: 9, Size: 9
So before calling l.RemoveAt(8), the size of the list is 10 items, with the largest index being 9 (indexes are 0 based, so in this case, the valid index numbers are 0-9). After calling l.RemvoeAt(8), the size of the list is only 10 items and the valid index ranges are 0-8, therefore and index of 9 will produce the error posted.
Issue#2:
Because the list resizes, the indexes do not match up anymore between two lists. Code time:
Dim l As List
l.Initialize
For x = 0 To 9
l.Add(x)
Next
Dim l2 As List
l2.Initialize
For x = 0 To 9
l2.Add(x)
Next
For x = 0 To l.Size -1
Dim y As Int
y = l.Get(x)
If y > 3 And y < 6 Then
l2.RemoveAt(x)
End If
Next
For x = 0 To l2.Size - 1
Log(l2.Get(x))
Next
Looking at your code, you probably expect this output
but you are really getting this
Why? Think about it. When l.Get(4) returns 4, we satisfy the If condition and perform l2.RemoveAt(4). That remove's the fifth element of l2, which contains a 4. Ok. Good so far. The problem is that now the sixth element, the number 5 now becomes the new fifth element and the seventh element, the number 6 becomes the new sixth element and so on. No l.Get(5) returns a 5. It meets the if condition. We call l2.RemoveAt(5), removing the sixth element of l2. Well, the sixth element is the number 6 and we remove it. As before, all the elements above move one down.(BTW, this code still suffers from issue#1).
How to solve this? When working with lists and removing items, work from the top of the list to the bottom:
Dim l As List
l.Initialize
For x = 0 To 9
l.Add(x)
Next
Dim l2 As List
l2.Initialize
For x = 0 To 9
l2.Add(x)
Next
'Work the list from top to bottom!
For x = l.Size -1 To 0 Step -1
Dim y As Int
y = l.Get(x)
If y > 3 And y < 6 Then
l2.RemoveAt(x)
End If
Next
For x = 0 To l2.Size - 1
Log(l2.Get(x))
Next
Output:
Apologies for the long explanation, maybe I could have said it shorter, but I thought some code examples would bring home the point. Now that I look at it, I'm pretty sure that is why you are getting duplicate entries (since the wrong items are being deleted out of your userlist list).