Results 1 to 3 of 3

Thread: vb.net remove from 2d list based on 3 subitems

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2013
    Posts
    3

    Question vb.net remove from 2d list based on 3 subitems

    I have two list of list of object's, based on three subitems of list1 if those subitems exists on an item of list2 then remove that from list2. I keep finding rows from list2 that exist in list1 and i am out of ideas.
    Code:
    Dim list1 As New List(Of List(Of Object))
    Dim list2 As New List(Of List(Of Object))
    Dim it As Integer = Nothing : Dim it2 As Integer = Nothing
    While it < List1.count
        While it2 < list2.Count
            If list1(it).Item(0).ToString = list2(it2).Item(0).ToString And list1(it).Item(3).ToString = list2(it2).Item(3).ToString And list1(it).Item(6).ToString = list2(it2).Item(6).ToString Then
                list2.RemoveAt(it2)
            End If
            it2 += 1
        End While
        it += 1 : it2 = 0
    End While

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

    Re: vb.net remove from 2d list based on 3 subitems

    What's in those inner lists? From the way you're using them, it looks like they should be classes with properties rather than lists with items. Can you please provide a FULL and CLEAR description of the data and what it represents?
    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
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: vb.net remove from 2d list based on 3 subitems

    What's in those inner lists?
    If the code is anything to go by ... nothing! They are never given any items. The whole procedure's baffling anyway. If a list in List1 contains items at 0,3, and 6 which are identical to the items in a list in List2 at those positions then delete the list from List 2? Also this is bound to run itself into the ground as it's committing the cardinal sin of counting forward in iterating a list from which items may be removed.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

Tags for this Thread

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