Results 1 to 8 of 8

Thread: 3rd Listbox Question..................

  1. #1

    Thread Starter
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827

    Post

    If you've not got too many entries in the list boxes, you could just use compare each entry in listbox 1 with every entry in listbox 2, and remove them if they're the same (using the removeitem method).

    Then again, if either are large lists, doing that would take absolutely ages. I expect there's a more efficient way of doing it. I don't know how off the top of my head, though.

  2. #2
    Addicted Member Smie's Avatar
    Join Date
    Jun 1999
    Location
    Columbus, OH
    Posts
    249

    Post

    The size can vary........its all user input.

  3. #3
    Member
    Join Date
    Jul 1999
    Location
    J-ville, NC
    Posts
    54

    Post

    This may help...

    Dim i%
    Dim x%

    For i% = 0 To List2.ListCount - 1
    For x% = 0 To (List1.ListCount - 1)
    If List2.list(i%) = List1.list(x%) Then List2.RemoveItem (i%)
    Next x%
    Next i%

    ------------------
    David Underwood
    Teen Programmer

    ICQ - 14028049
    E-mail - [email protected]



  4. #4
    Addicted Member Smie's Avatar
    Join Date
    Jun 1999
    Location
    Columbus, OH
    Posts
    249

    Post

    I get the error

    Next without For

    but the for is there! any clue whats wrong?

  5. #5
    Member
    Join Date
    Jul 1999
    Location
    J-ville, NC
    Posts
    54

    Post

    How are you using the code in your program? Try adding 2 listboxes to a form, add similar and different letters into the listbox and paste that code into the form load. You'll see it'll remove anything that's the same in the second listbox

    ------------------
    David Underwood
    Teen Programmer

    ICQ - 14028049
    E-mail - [email protected]



  6. #6
    Addicted Member Smie's Avatar
    Join Date
    Jun 1999
    Location
    Columbus, OH
    Posts
    249

    Post

    I have everything setup correctly
    But when I go to run the procedure, it says that there is no "For" to got with the "Next" I have no clue why....

  7. #7
    Addicted Member Smie's Avatar
    Join Date
    Jun 1999
    Location
    Columbus, OH
    Posts
    249

    Post

    What would I do, so that when the form loads, if any information from list 1 is the same as list 2, the information that is the same would be removed?

  8. #8

    Thread Starter
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827

    Post

    Try using the find option in the edit menu, and search for all the instances of 'For', and all the instances of 'Next' in the area where the problem is. Make sure there's the same number of Fors and Nexts. Could be there's something missing from another part of your code.

    Also make sure you haven't written:

    For x ...
    For i ...
    ...
    Next x...
    Next i...

    That's the kinda thing you might miss at first glance.

    When I said large, I meant, like, hundreds/thousands of items in the lists. Since you're talking about user input, I suppose there won't be that many, so this way should only take a second or two.

    One thing to note though: when you remove an item from listbox 2, if you move on to the next x, you'll miss the item in the list which is now in the position which you just deleted from. You see what I mean? Say you remove the 3rd item in the list, the 4th item will move up to take its place, so if you move on without checking again, you'll miss that item.


    [This message has been edited by HarryW (edited 01-13-2000).]

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