Results 1 to 2 of 2

Thread: Remove Duplicate Lines

  1. #1

    Thread Starter
    Addicted Member articwoof's Avatar
    Join Date
    Oct 2004
    Location
    Alaska
    Posts
    163

    Remove Duplicate Lines

    I have a list of item codes for a data entry and trying to make a simpel vb app to help remove duplicates like:
    The entries are in a multiline textbox
    123456789
    123449112 <- Orignal
    787871213
    123449112 <- Duplicate

    So it removes only duplicates and keeps at leaste one of each code.
    [+] - My Portfolio/Blog :: RattleSoft

  2. #2
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Remove Duplicate Lines

    One easy way would be to parse the text line by line, and put it in a ListView (with Sorted set to True). The use this For Next loop:

    VB Code:
    1. If List1.ListItems.Count = 0 Then
    2.             Exit Sub
    3.         Else
    4.             J = List1.ListItems.Count
    5.         End If
    6.        
    7.         For I = J To 2 Step -1
    8.             If List1.ListItems.Item(I).Text = List1.ListItems.Item(I - 1).Text Then
    9.                 List1.ListItems.Remove J
    10.             End If
    11.         Next I

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