|
-
Jan 12th, 2000, 02:34 AM
#1
Thread Starter
Frenzied Member
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.
-
Jan 12th, 2000, 06:00 AM
#2
Addicted Member
The size can vary........its all user input.
-
Jan 12th, 2000, 06:13 AM
#3
Member
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]
-
Jan 12th, 2000, 06:59 AM
#4
Addicted Member
I get the error
Next without For
but the for is there! any clue whats wrong?
-
Jan 12th, 2000, 07:10 AM
#5
Member
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]
-
Jan 12th, 2000, 07:17 AM
#6
Addicted Member
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....
-
Jan 12th, 2000, 12:59 PM
#7
Addicted Member
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?
-
Jan 12th, 2000, 05:43 PM
#8
Thread Starter
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|