4
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by poojavb
1

See if this helps :

Private Sub FindMySpecificString(ByVal searchString As String)
    ' Ensure we have a proper string to search for.'
    If searchString <> String.Empty Then
        ' Find the item in the list and store the index to the item.'
        Dim index As Integer = listBox1.FindStringExact(searchString)
        ' Determine if a valid index is returned. Select the item if it is valid.'
        If index <> ListBox.NoMatches Then
            listBox1.SetSelected(index, True)
        Else
            MessageBox.Show("The search string did not find any items in the ListBox that exactly match the specified search string")
        End If
    End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    FindMySpecificString(TextBox1.Text)
End Sub

Edited by Jx_Man: code tag

0

One you say listBox, and ones listView? What is it gonna be?

but when I dont type anything, the listview items gone..,

What is thill suppose to mean?

0
Dim abc As String
    abc = TextBox4.Text
    If abc = "" Then
        MsgBox("Empty")
    Else
        If ListBox1.FindString(abc) <> True Then
            MsgBox("Got it")
        Else
            MsgBox("Not")
        End If
    End If

Edited by poojavb

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.