Hello Programmers,
Your newbie programmer wants to ask a help regarding his program (That’s Me :D). My program is in Visual Basic 2010, I want to ask how I can search a words or strings. I use TextBox, ListBox and Button for my program. For detailed explanation about what my problem is, I provide image below:
Above image is my program design, as you can see there’s a Button(Search), TextBox(Search Here) and ListBox(w/a words of “Array’, “Bytecode”, “Compile”, “Computer”, “Debug”, Etc…) All I want to learn is how to rearranged/filter the words in ListBox when I typed a word in TextBox(Search Here) and click the Button(Search). For example, I type the word “Compile” in TextBox(Search Here), when I click the Button(Search), the word in the ListBox “Compile” must be in top instead of word “array” and “bytecode” and next word must be “Compiler” as it is same near in the word “Compile”.
The codes I use in my Button(Search) is this:
Dim count As Integer = (ListBox1.Items.Count - 1)
Dim words, wordsB As String
Dim spaceCharCounter As Integer = 0
For i = 0 To count
words = ListBox1.Items.Item(i)
For j = 0 To words.Length - 1
If spaceCharCounter >= 2 Then
wordsB += words.Substring(j, 1)
ElseIf words.Substring(j, 1) = Chr(32) Then
spaceCharCounter += 1
End If
Next
If InStr(wordsB, TextBox1.Text) Then
ListBox1.Items.Add(ListBox1.Items.Item(i))
End If
words = Nothing
spaceCharCounter = 0
wordsB = Nothing
Next
My codes above will just highlight the items in the ListBox that is matched to the word I search.
Please help me guys... As you can see in my program design I try to create a simple dictionary of programming. Comment your Comments, Suggestions and Any Idea that can help regarding this program :D
Thanks in Advance :D