Results 1 to 2 of 2

Thread: Trouble searching list box

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2015

    Trouble searching list box

    I am using this sub to search for a string in my Listbox, but I get the following error:

    An unhandled exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll

    Additional information: Conversion from type 'FileInfo' to type 'String' is not valid.

     Private Sub Button11_Click_11(ByVal sender As System.Object, ByVal e As System.EventArgs) _
          Handles Button11.Click
            Dim count As Integer = (music.Items.Count - 1)
            Dim words As String
            For a = 0 To count
                words = music.Items.Item(a)
                If InStr(words.ToLower, TextBox1.Text.ToLower) Then
                    music.SelectedItem = words
                End If
        End Sub
    I can't figure whats wrong..

  2. #2

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