| Fast way to remove all duplicates (dupes) in a ListBox Description:This method removes all duplicates in a listbox, regardless if sorting is turned on or not. AND it's fast, short and simple (no Double loops like In some other submissions). It's also case-insensitive. By: Fredrik Schultz Private Sub RemoveDupes(lst As ListBox) Dim iPos As Integer iPos=0 '-- if listbox empty then exit.. If lst.ListCount < 1 Then Exit Sub Do While iPos < lst.ListCount lst.Text = lst.List(iPos) '-- check if text already exists.. If lst.ListIndex <> iPos Then '-- if so, remove it and keep iPos.. lst.RemoveItem iPos Else '-- if not, increase iPos.. iPos = iPos + 1 End If Loop '-- used to unselect the last selected l ' ine.. lst.Text = "~~~^^~~~" End Sub |
Fast way to remove all duplicates |
Express News India | Freelance ecommerce web development India