1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Searching Exact String In Listbox for multiple items ?

Discussion in 'Visual Basic .NET' started by polas1, Mar 8, 2015.

  1. polas1

    polas1 Newbie

    Joined:
    Mar 8, 2015
    Messages:
    1
    Likes Received:
    0
    Hi everybody.

    It searches multiple items in the listbox not correctly. Im assuming im going to need to loop through the listbox somehow and find all matching and extact items in listbox3 ?

    I have button for scrape google results 2 listboxes and search button.

    i have a TextBox containing Text.
    i have a list of Strings in a ListBox called ListBox1.
    i want to see if each String in ListBox1 is present within the text of the TextBox
    If it is present, i want to add that Strings to a ListBox called ListBox3

    I just want to add exact results in listbox3 from listbox1 when i enter some keyword into textbox one i click button1 to scrape urls from google and add to listbox1 and when i click the buton find it must find and add exact urls from listbox1 to listbox3 which i scraped from google urls.

    The code is working but it adds not the same urls which is in the listbox1 when click on the url in the listbox3 it opens the link in google chrome but not that but different and i do not why it does that

    When i click on the link in listbox1 it opens correct page in google chrome.

    Here is what i have for so far but this is not what i want.

    Code:

    ListBox3.Items.Clear()
    For Each ItemText As String In ListBox1.Items
    If ItemText.Contains(TextBox1.Text) Then
    ListBox3.Items.Add(ItemText)
    Label5.Text = ListBox3.Items.Count
    End If
    Next


    look at the picture:

    K6eq6D.jpg

    it finds Wrong urls and not match in the listbox from textbox.

    How to fix it and make it search exact what i type in textbox and add from listbox1 found items to listbox 3 and count items ?

    Sure it shows in the listbox3 correct urls but when i click on the link it open not the same url as shown in listbox3.
     
    Last edited: Mar 8, 2015
  2. CrackFantasy

    CrackFantasy Junior Member

    Joined:
    Jun 22, 2014
    Messages:
    166
    Likes Received:
    77
    Try this:
    if itemText = textbox1.text then
    do something...
     
  3. roadhamster

    roadhamster Regular Member

    Joined:
    Mar 12, 2012
    Messages:
    341
    Likes Received:
    244
  4. lajcik

    lajcik Junior Member

    Joined:
    Aug 27, 2011
    Messages:
    103
    Likes Received:
    18
    Location:
    Poland
    Home Page:
    Can't you just go for 2 for each loops? :)