Results 1 to 6 of 6

Thread: A FASTER way to compare and remove duplicates between 2 listboxes

Hybrid View

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    4

    A FASTER way to compare and remove duplicates between 2 listboxes

    Depending on the data being used, I can have up 10,000 items in each of the 2 ListBoxs. I need to find and remove any Duplicates between the 2.
    I am currently using the method of select and Item from Listbox1 and search in Listbox2. If I find a match, then remove both items. This goes back and forth until all the duplicates have been removed. This take some time.

    Is there a faster way of accomplishing my goal. I have searched the NET for the past 2 days trying to find ways to get there. Still have not come with something that works for me.

    Currently have the code in Old VB6 and VB2008 Express.

    Any help would be much appreciated.

    Regards,
    B.Giles

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: A FASTER way to compare and remove duplicates between 2 listboxes

    It's probably a bit ridiculous to have 10,000 items in a ListBox to begin with. Why have you loaded the data into the ListBoxes if you don't want all the items? Should you not be, at the very least, removing the duplicates first?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    4

    Re: A FASTER way to compare and remove duplicates between 2 listboxes

    Yes, I understand that 10,000 items in a Listbox is a little much.

    The list boxes are being populated from me parsing a text file(for each) for specific data, combining 2 results into a string and then adding it to the listbox then comparing the data between the 2 boxes.

    Due to my lack of knowledge and still learning VB, it was the best I could come up with. I have not been task to create something like this before, so its all new to me.

    Thanks your response.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: A FASTER way to compare and remove duplicates between 2 listboxes

    A ListBox, like other controls, is to provide the user with a way to interact with your application. You don't put data into controls in order to work with them in code because the visual aspect makes them significantly slower. At the very least should be using just regular collections to store the data and then work with it in code before, if appropriate, displaying the data to the user in one or more controls. Perhaps you should give us a more complete description of what you're trying to do and then we can advise the best way to do it.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    4

    Re: A FASTER way to compare and remove duplicates between 2 listboxes

    Jmcilhinney, Thank you for your time and willing to help.
    I will put something together and post it when I get back to work on Monday.

    Regards,
    B.Giles

  6. #6

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    4

    Re: A FASTER way to compare and remove duplicates between 2 listboxes

    Requested Info:

    I have 2 files that contain the following info.
    **************************************

    Header Info
    H:CREATED_BY=DEMO
    H:INPUTFILENAME=DEMO
    H:OUTPUTFILENAME=DEMO.dem
    H:CCG_CODE=DEMO
    H:PROD_H=DEMO
    H:BASEASSYNUMBER=123412341234
    H:ORIGINAL_CPN=12-34567-89
    H:BASEASSYDESCRIPTION=DEMO Description
    H:BASEASSYCUSTREV=AB
    H:BASEASSYSLRREV=01

    Parts(can be up to 300+ of the sections)
    :BEGIN:
    LEVEL=1
    PARTNUM=123456789101
    PARTDESC=DEMO DESCRIPTION
    PARENTPARTNUM=123412341234
    PARTREV=15
    RMA=N
    FPN=
    QTY=23
    UM=EA
    REFDES=C3313,C3512,C3513,C3314,C3315,C4413,C3316,C3317,C3446,C3501
    REFDES=C3514,C3584,C4239,C3175,C3176,C3177,C3178,C3179,C3180,C3181
    REFDES=C3182,C3183,C3184
    REFDES_1=C3512,C3513,C4413
    REFDES_2=C3313,C3314,C3315,C3316,C3317,C3446,C3501,C3514,C3584,C4239
    REFDES_2=C3175,C3176,C3177,C3178,C3179,C3180,C3181,C3182,C3183,C3184
    REFDES_3=
    REFDES_4=
    MANUFACTURER_INFO=DEMO1
    MANUFACTURER_INFO=DEMO2
    MANUFACTURER_INFO=DEMO3
    MANUFACTURER_INFO=DEMO4
    ORIGINAL_CHILD_CPN=98-7654-32
    BAAN_CHILD_CPC_PN=
    PCB=
    :END:

    **************************************

    Right now I am creating a string with PARTNUM and one item from the REFDES_1 or REFDES_2, depending on the side. Not using the plain REFDES, which combines both 1 & 2. Also, as you can see, the REFDES_2 is split into 2 rows.
    As it searches, is adds the string to the list box.

    The string looks like this.
    123456789101 C3512
    123456789101 C3513
    123456789101 C4413

    There can be up 300+ of the these "PART" sections with up to 1500-2000 REFDES items in each. Just depends on the product being built.

    The program I have now, has 4 lists boxes.

    Product-A
    Box for REFDES_1
    Box for REFDES_2

    Product-B
    Box for REFDES_1
    Box for REFDES_2

    After the compare is shows the differences between the 2 for both sides.

    So basically, what I think I need, is to somehow open one file and load both the searches(REFDES_1 & REFDES_2) to 2 arrays and then load the other file with the same process. Then compare the 4 arrays and populate the 4 list boxes.

    Yes, I know its complicated.

    Hope that is enough info.

    Thanks to all who are willing to direct into the right direction. I am still learning on my own. All I have is the NET, examples and the source code for our app's that the GUY who use to do the programming, left behind.

    B.Giles

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