Click to See Complete Forum and Search --> : 3rd Listbox Question..................
HarryW
Jan 12th, 2000, 01:34 AM
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.
Smie
Jan 12th, 2000, 05:00 AM
The size can vary........its all user input.
X_Darknight_X
Jan 12th, 2000, 05:13 AM
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 (http://www.icq.com/14028049)
E-mail - darknight23@hotmail.com
Smie
Jan 12th, 2000, 05:59 AM
I get the error
Next without For
but the for is there! any clue whats wrong?
X_Darknight_X
Jan 12th, 2000, 06:10 AM
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 (http://www.icq.com/14028049)
E-mail - darknight23@hotmail.com
Smie
Jan 12th, 2000, 06:17 AM
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....
Smie
Jan 12th, 2000, 11:59 AM
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?
HarryW
Jan 12th, 2000, 04:43 PM
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).]
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.