CodeItBetter Programming Another VB Programming Blog

How to kill duplicates in Listview control

Posted on January 4, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'Controls - How to kill duplicates in Listview control
Option Explicit
 
Public Sub ListViewKillDupelicates()
    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
 
'How can I call this procedure:
'Private Sub cmdKillDupelicates_Click()
'    ListViewKillDupelicates
'End Sub
Filed under: Controls Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.