Results 1 to 4 of 4

Thread: identical items in a listbox

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    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).]

  2. #2
    New Member
    Join Date
    Nov 1999
    Posts
    14

    Post

    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

  3. #3
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892

    Post

    Huh???

    ------------------
    Yonatan
    Teenage Programmer
    E-Mail: RZvika@netvision.net.il
    ICQ: 19552879
    AIM: RYoni69

  4. #4
    Lively Member
    Join Date
    May 1999
    Location
    India
    Posts
    97

    Post

    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



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