Results 1 to 2 of 2

Thread: vb.net go through all items in listbox and select closest matches

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2011
    Posts
    137

    Smile vb.net go through all items in listbox and select closest matches

    I have one button find,2 textboxes and one listbox.
    I need code which would go through all items in listbox and select only closest matches and add them to another multiple textbox2 as you type in textbox1.

    It find text as you type in textbox1 correctly but then i click the button find it can't find all sentence only one word like "live" not like "i live ok".

    i have only this code for so far.

    Code:
     Dim s As String = Me.TextBox1.Text
            Dim lb As ListBox = Me.ListBox1
            lb.SelectedIndex = -1
            If s.Length > 0 Then
                For i As Integer = 0 To lb.Items.Count - 1
                    If lb.Items(i).ToString.Contains(s) Then
                        lb.SelectedIndices.Add(i)
                    End If
                Next
            End If
    what a code is doing so it's trying to find exact words/strings in listbox using textbox and highlight them if they found in listbox.
    But there is the problem with this code is that one can't search and find all words like these "i live ok" without the quotes.

    It can find only entered text in textbox like this "live"
    It can't find them i live ok it finds only one word not all sentence.

    I need code that which can search through all items in listbox and select all words like "i live ok" not like so "live".
    to understand it better how is working i have some examples.

    Name:  1.png
Views: 1503
Size:  27.3 KB

    Name:  2.png
Views: 1387
Size:  37.0 KB
    Last edited by polas; May 11th, 2013 at 04:03 AM.

Tags for this Thread

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