Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

lists question

Status
Not open for further replies.

dbayer

Programmer
Jul 17, 2000
2
US
I need to subtract one list from another, or in other words find all the mismatches from two different lists.  Can anyone help?
 
A nice visual way to do this would be with two listboxes.<br><br>Fill the two listboxes with your data, then:<br><br>for each item in list1<br>&nbsp;&nbsp;search list2 - removeitem if found<br>next item<br><br>(That isn't VB code by the way - just a quick way of looking at how the method might work.)<br><br>If you need to make the search faster - make list2 sorted and you could do a binary chop on it.<br><br>for each searchitem<br>&nbsp;&nbsp;&nbsp;compare searchitem with item halfway through list2<br>&nbsp;&nbsp;&nbsp;is it bigger? smaller? the same?<br>&nbsp;&nbsp;&nbsp;the same - gotcha<br>&nbsp;&nbsp;&nbsp;bigger -- do the search again but in the upper half of list2<br>&nbsp;&nbsp;&nbsp;smaller -- do the search again but in the lower half of list2<br> <p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top