Results 1 to 3 of 3

Thread: removing duplicates

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2001
    Location
    here and their
    Posts
    35

    removing duplicates

    how would you have a listbox automaticly remove duplicates.
    ITs out their

  2. #2
    Matthew Gates
    Guest
    Try this:


    VB Code:
    1. Private Sub RemoveDuplicates(list As ListBox)
    2.     Dim i As Integer, x As Integer
    3.     For i = 0 To list.ListCount - 1
    4.         For x = 0 To list.ListCount - 1
    5.             If i <> x Then
    6.                 If list.list(i) = list.list(x) Then
    7.                     list.RemoveItem (x)
    8.                 End If
    9.             End If
    10.         Next x
    11.     Next i
    12. End Sub
    13.  
    14. Private Sub Command1_Click()
    15.     Call RemoveDuplicates(List1)
    16. End Sub

  3. #3
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    If the listbox is sorted you could do something like

    For t=lstListBox.Listcount-1 to 1 step -1
    if lstListBox.list(t)=lstListBox.list(t-1) then
    lstListBox.RemoveItem(t)
    End If
    Next t

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width