Hi all
I am creating a movie player which lists movie files from various folders/subfolders in a combobox (tsFileList). I'd like to be able to enter the movie name into a textbox (txtSearch), find that text in the combobox (using instr), then automatically select the found item.
I'd like to use instr as some of the items in the combobox contains full file paths.
Any help would be greatly appreciated as I can't seem to find an answer for this in a web search.
Regards
Colin
Loading
Colin WearmouthPosted Feb 2, 2010, 3:48 AM
I did find a solution as shown below, if anyone is interested. This code also allows for continuing the search from the previously found result(s).
[CODE]
Dim n As Integer = 0
Dim sphrase As String = Me.txtSearch.Text
'====================================================================
Dim found As Boolean = False
If txtSearch.Text = "" Then Exit Sub
1:
For x As Integer = n To tsFileList.Items.Count - 1
If tsFileList.Items(x).ToString.Contains(StrConv(txtSearch.Text, VbStrConv.ProperCase)) Then
tsFileList.SelectedIndex = x
found = True
prompt = MsgBox("Search again?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "")
If prompt = vbNo Then
Me.txtSearch.Clear()
Me.txtSearch.Text = "Enter Search Phrase Here"
Exit Sub
ElseIf prompt = vbYes Then
n = x + 1
GoTo 1
Exit For
End If
End If
Next
Me.txtSearch.Text = "Enter Search Phrase Here"
[/CODE]
Once again thanks and regards
Colin
Hiren SoniPosted Jan 30, 2010, 11:02 PM
see attached file