PDA

Click to See Complete Forum and Search --> : identical items in a listbox


netSurfer
Nov 24th, 1999, 12:11 AM
I assume that you are looking for a keyword, and whatever values are being returned are getting dumped into a list box. There are 2 things you can do, either dump the returning variables into an array, checking each existing array element to see if it exists, or before you put the value into the list box, check all the existing elements of the list box. I'm not sure which would be faster, depends on how many results will be returned. This is assuming of course that the results being returned are being returned one at a time somewhere. Where ever that is, put your loop there.

Assuming you have a list box (lstResults), call the DumpResults function for each result you find, sending the result string.
like this:
strResult = "Result string"
DumpResult(strResult)

function DumpResults(strTemp as string)
Dim inti As Integer, intJ As Integer
intJ = lstResults.ListIndex 'stores what ever index you're at
For inti = 0 To lstResults.ListCount - 1
lstResults.ListIndex = inti
If lstResults.Text = strTemp Then Exit Function

Next inti
lstResults.AddItem strTemp
lstResults.ListIndex = intJ
end function


[This message has been edited by netSurfer (edited 11-24-1999).]

moocow
Nov 24th, 1999, 11:06 AM
When my program searches for a keyword and returns with the results I find that I get the same link in my listbox a number of times!

How can i get rid of these multiple links i don't need?

thanx,

evilmonkeyIII

Yonatan
Nov 24th, 1999, 11:38 AM
Huh???

------------------
Yonatan
Teenage Programmer
E-Mail: RZvika@netvision.net.il
ICQ: 19552879 (http://www.icq.com/19552879)
AIM: RYoni69

Gaurav
Nov 24th, 1999, 04:29 PM
Aah the multiple blues of the listbox!! :)

Take a look at the Dictionery objec in VB 6.0, its equivalent to the Associative array in Perl. will solve your problem.

If u canna figure it out, drop me a line n i'll write out some sample code for u :)

cheers,

------------------
Gaurav Mahindra
gmahindra@extentia.com