Results 1 to 6 of 6

Thread: listboxes, please help..

  1. #1
    Guest
    i have three listboxes:
    one is filled with numbers(LONG).
    the second is filled with numbers(LONG).
    the numbers in the second could be duplicates
    of what is in the first listbox, and even those
    numbers may be listed more than twice.

    how can i do a search using the number from the
    first listbox and pulling the same number(s) from
    the second listbox and add those that are found to
    the third listbox.

    this thing has me confused, plus fighting the flu while
    trying to think...

    thankx for all help,
    larryn

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Try this out:
    Code:
        For x = 0 To List1.ListCount - 1
            For y = 0 To List2.ListCount - 1
                If List1.List(x) = List2.List(x) Then Exit For
            Next y
            If y < List2.ListCount Then List3.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.

  3. #3
    Guest
    that was pretty fast coding,

    but the part:
    Code:
          If List1.List(x) = List2.List(x) Then Exit For
    List2.List(x) does not loop through the list,
    it stays on the first number for the times there
    are numbers in the second listbox.

    is there a way to get it to loop?

  4. #4
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357
    Uhh, kedaman, I dont think that will work. Normally in a For/Next loop you do something with the variable you are using for the loop counter, but your code in the "For y..." loop keeps checking the same thing. I think you might need to change it to this:
    Code:
        For x = 0 To List1.ListCount - 1
            For y = 0 To List2.ListCount - 1
                If List1.List(x) = List2.List(y) Then Exit For
            Next y
            If y < List2.ListCount Then List3.AddItem List1.List(x)
        Next x
    ~seaweed

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Sorry guys! hope that got clear now
    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.

  6. #6
    Guest
    you guys are great, thankx!

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