Advertisement
C_Volume2 Custom Controls/ Forms/ Menus #70946

Dedupe ListView Function with an Database. UPDATED! Also shows how to do some simple math

My Code commenting sucked, My bad. So heres the update! This funtion is meant to be used when passing values from another control to a listview control with a database. I needed a way to keep duplicate entries away in the recieving Listview. The funtion is called after the row insertion on a double click event or Drag and drop.It works because the index is set dynamicaly by the database values.If used out of context it WILL delete everything, which in fact, does suck. I used LCase incase you want to pass a nonnumerical value(which i did and then did not), but you can remove it, no harm, no foul. Hope this helps. Feedback is very welcome. Please Feedback, Please.

AI

AI-sammanfattning: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Källkod
original-source
Public Sub RemoveDupes(listview As listview)
Dim i As Integer
Dim x As Integer
For i = listview.ListItems.Count To 1 Step -1 ' Works backwards avoiding error
 For x = listview.ListItems.Count To 1 Step -1 ' same
 If i = x Then GoTo Nextx 'adds item if not in recieving listview.Once one is in there it will actually start the below routine
 
 If LCase(listview.ListItems(x)) = LCase(listview.ListItems(i)) Then
 listview.ListItems.Remove (i) 'that should be clear
 listview.Refresh 'Better to be safe then dead
 i = listview.ListItems.Count 'sets i to current record count so you dont get an error when the loop starts again
 End If
Nextx:
 Next x
Next i
End Sub
Originalkommentarer (3)
Återställd från Wayback Machine