Im a beginner to VB.net and im trying to code for a search button which will compare a string from a textbox to a combo box list?

Here is what Im instructed to do:
The Search button will look for the phrases containing the phrase the user has specified in the text box and display all such phrases (each on a separate line) in a message box. Search should first check that the user has entered something in the text box. Give an appropriate message if not. Remember to nest any checks so that only one message displays at a time. If the text box is not empty, use a For/Next loop to check each item in the combo box to see if it has the phrase entered by the user in the text box. (You won’t need a foundBoolean here since the entire combo box must be checked even if you’ve found one.) If the phrase matches, add it to a String that you will later display in a message box with all the matching phrases. Remember you want each phrase on a separate line in the message box. You can use &= to keep adding to the String. When you declare this String you’ll have to set it initially to “. After the loop is finished, check whether there is anything in the String. If not, inform the user via a message box that there are no phrases containing the user-input phrase and call Clear Labels. If the String isn’t empty, display a message box with all the phrases from the combo box that matched the input phrase. Then call Clear Labels.
Do whatever is necessary to match phrases regardless of case. So, for example, if the user enters kent it will match Kent.
One point about the items from the combo box that you are comparing to the text box has to do with Option Strict On. ComboBox.Items(indexInteger) is not regarded as a String. When you enter the For/Next loop you’ll have to use ToString to convert it before you can compare it to the text box Text property which is a String.

Here is what I have so far:
Dim loopIndexInteger As Integer
Dim maximumInteger As Integer
maximumInteger = listComboBox.Items.Count - 1
Dim listCompareString As String = ""
Dim textCompareString As String

If inputTextBox.Text = "" Then
MessageBox.Show("You must enter something in the text box")
Else
For loopIndexInteger = 0 To maximumInteger
listCompareString = listComboBox.Items(loopIndexInteger).ToString()
listCompareString = listCompareString.ToUpper()
textCompareString = inputTextBox.Text.ToUpper()

Next


End If

Please help me finish this code, I have no clue on how to compare the textbox
string to the combobox list and then display it in a messagebox string?

Im not a vb/VB.net programmer and I had a hard time understanding your question... where ambiguous, I left comments that need to be coded in, but this might help you along the way.

Dim loopIndexInteger As Integer
Dim listCompareString As String,textCompareString,matchString As String
If inputTextBox.Text = Nothing Then
MessageBox.Show("You must enter something in the text box")
Else
textCompareString = inputTextBox.Text.ToUpper()
For loopIndexInteger = 1 To listComboBox.Items.Count
listCompareString = listComboBox.Items(loopIndexInteger - 1).ToString().ToUpper()
if matches(textCompareString, listCompareString) then
matchString &= listComboBox.Items(loopIndexInteger -1).ToString()
matchString &= vbnewline
end if
Next
'call clear fields
if matchString = Nothing then
MessageBox.Show("None Found")
else
MessageBox.Show(matchString)
end if
End If

function matches(byval string1 As String, byval string2 As String) As Boolean
'your code here
end function

This article has been dead for over six months. Start a new discussion instead.