CodeItBetter Programming Another VB Programming Blog

Duplicate Listview Item Remover

Posted on June 29, 2011
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'Controls - Duplicate Listview Item Remover
Public Sub ListViewKillDupes()
    Dim Search1 As Long
    Dim Search2 As Long
    Dim KillDupe As Long
    KillDupe = 0
    For Search1& = 1 To ListView1.ListItems.Count - 1
        For Search2& = Search1& + 1 To ListView1.ListItems.Count - 1
            KillDupe = KillDupe + 1
            If ListView1.ListItems.Item(Search1&) = ListView1.ListItems.Item(Search2&) Then
                ListView1.ListItems.Remove (Search2&)
                Search2& = Search2& - 1
            End If
        Next Search2&
    Next Search1&
End Sub
 
'Call it like this:
'
'Private Sub Command1_Click()
'   Call ListViewKillDupes
'End Sub
Filed under: Controls Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.