27 | 07 | 2017

Remove Duplicates from Listview

 Function to delete duplicates form a listview

 

Function RemoveDuplicates(ByVal lstView As ListView) As Boolean

Dim itemI As ListViewItem

Dim itemJ As ListViewItem

Dim progress AsIntegerDim count AsIntegerDim ProgressDupCounter AsInteger = lstView.Items.Count


For i As Integer = lstView.Items.Count - 1 To 0 Step -1

itemI = lstView.Items(i)

progress = progress + 1

' start one after hence +1For z AsInteger = i + 1 To lstView.Items.Count - 1 Step 1

itemJ = lstView.Items(z)

If itemI.Text = itemJ.Text Then'duplicate found, now delete duplicate

lstView.Items.Remove(itemJ)

count = count + 1

Exit For 

End If

Next z

Next (i)

End Function


Login

Sign up now and upload your code to the website.

Help us to continue.....
Statistics
Articles View Hits
2311526
Latest Articles