> Vb.net remove both duplicate and original record in listview?

Vb.net remove both duplicate and original record in listview?

Posted at: 2014-12-18 
How do I remove the record in listview if the record has a duplicated one? and it will also delete the original one. For example:

Column1

AAA

BBB

CCC

AAA

DDD

In this case, both the first and fourth one will be deleted. The final output will be

Column1

BBB

CCC

DDD

Here's my code

Dim RemovedItemsIndexs As New Collection

Dim ctr, ctr2 As Integer

ctr = 0

Dim listviewctr As Integer = ListView3.Items.Count

listviewctr = listviewctr - 1

Do

ctr2 = 0

Do

If ListView3.Items.Item(ctr).Text = ListView3.Items.Item(ctr2).Text And ListView3.Items(ctr).SubItems(1).Text = ListView3.Items(ctr2).SubItems(1).Text Then

If Not RemovedItemsIndexs.Contains(ctr) Then

RemovedItemsIndexs.Add(ctr, ctr)

End If

If Not RemovedItemsIndexs.Contains(ctr2) Then

RemovedItemsIndexs.Add(ctr2, ctr2)

End If

End If

If ctr2 <> listviewctr Then

ctr2 = ctr2 + 1

Else

GoTo down

End If

Loop Until ctr = listviewctr + 1

down:

ctr = ctr + 1

Loop Until ctr = listviewctr + 1



For index As Integer = 1 To RemovedItemsIndexs.Count

ListView3.Items.RemoveAt(RemovedItemsIndexs(index))



Next

Please help, Thank you.