Search Combo Box

no-sweat

New member
Joined
Apr 11, 2005
Messages
2
Programming Experience
Beginner
this is suppose to search a combo box for (ends with) text in a text box


VB.NET:
 Private Sub searchButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles searchButton.Click
        Dim counterInteger As Integer
        Dim addressListString As String = ""
        If domainNameTextBox.Text <> "" Then
            For counterInteger = 0 To addressComboBox.Items.Count - 1
                If domainNameTextBox.Text.EndsWith(addressComboBox.Items(counterInteger).ToString) Then
                    addressListString &= addressComboBox.SelectedIndex.ToString
                End If
            Next counterInteger
            MessageBox.Show(addressListString, "here da list")
        Else
            MessageBox.Show("Please enter a search string.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End Sub

if it cant find the search term, then i wants a message box to come up and say so. if it can, i want it to continue searching thru the combo box and add each item it finds to a variable, and display that variable in a message box.

this is so annoying. arent there any examples of this somewhere. my worthless book has nothing. plz help :(
 

Paszt

Staff member
Joined
Jun 3, 2004
Messages
1,500
Location
Raleigh, NC - USA
Programming Experience
Beginner
I think you've just reversed the operators in the If statement.
Try this:
VB.NET:
If addressComboBox.Items(counterInteger).ToString.EndsWith(domainNameTextBox.Text) Then
There's some spaces added to EndsWith for some reason...?
 
Top Bottom