Results 1 to 8 of 8

Thread: ****----Merging Lists----*****

  1. #1

    Thread Starter
    Lively Member mykg4orce's Avatar
    Join Date
    Oct 2000
    Location
    CANADA
    Posts
    92

    Exclamation

    how can i merge two lists into one, this is the main question.

    these two listboxes contain, three items: Name, Phone, Address.

    Now how can they both be merged???

  2. #2
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    do you mean like list1 items on top of list2 items?
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  3. #3

    Thread Starter
    Lively Member mykg4orce's Avatar
    Join Date
    Oct 2000
    Location
    CANADA
    Posts
    92
    no i mean it merges the two of them into one so that if one lising exists in the other list the merged list would only contain one of those listings. Meaning if one Name, Phone, Address is in list #1 and in list #2 then when i merge the merge list will only have one Name, Phone, Address and not the same thing twice.

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I guess you need something like this:
    Code:
    For x = 0 To List1.ListCount
        For y = 0 To List2.ListCount - 1
            If List1.List(x) Like List2.List(y) Then Exit For
        Next y
        If y = List2.ListCount Then List2.AddItem List1.List(x)
    Next x
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    Lively Member mykg4orce's Avatar
    Join Date
    Oct 2000
    Location
    CANADA
    Posts
    92
    i have tried the above method but it doesn't seem to work, please advise an other way. remember its like putting the two lists together, and taking out duplicate items

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    The code should work, but depends how you want the result to be. It goes trough each item in list1 and compares it with all items in list2, and refueses to add it whenever it founds a match.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7

    Thread Starter
    Lively Member mykg4orce's Avatar
    Join Date
    Oct 2000
    Location
    CANADA
    Posts
    92
    it only adds the items from the first list to the lstmerged it doesn't add any of the items from the second list

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Well why didn't you say so?
    Code:
    For y = 0 To List2.ListCount - 1
        lstmerged.AddItem List2.List(y)
    Next y
    
    For x = 0 To List1.ListCount
        For y = 0 To List2.ListCount - 1
            If List1.List(x) Like List2.List(y) Then Exit For
        Next y
        If y = List2.ListCount Then lstmerged.AddItem List1.List(x)
    Next x
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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