|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DUMB question about IndexOfis not working. And it is something really simple too. I have a listbox of mp3s (flbMp3s). I have a textbox (txtSearch). I have the directory of the mp3s (System.IO.Directory.GetFiles). I want to search the directory from the text in the textbox, adding to the listbox if there is a match. I have tried file.IndexOf(txtSearch.Text), file.Contains(txtSearch.Text), and even InStr(file, txtSearch.Text). What am I missing? Is there an easier way to do this? I just want to search for specific artists, songs, etc. This isn't hard... WHAT IS GOING ON!!! heh. Thanks, Josh Dim file As String Dim mp3sPath As String = flbMp3s.Path If (txtSearch.Text <> "") Then 'clear listbox flbMp3s.Items.Clear() 'loading each file in working direcrtory of application For Each file In System.IO.Directory.GetFiles(flbMp3s.Path) 'storing the filename into listbox items collection If (InStr(file, txtSearch.Text) > 1) Then flbMp3s.Items.Add(file) End If Next End If
Show quote
Hide quote
"Nonee" <N***@none.com> schrieb Maybe it's because an "A" is not an "a"?> Ok ok... I have been staring at this for a generation or so now and > it is not working. And it is something really simple too. I have a > listbox of mp3s (flbMp3s). I have a textbox (txtSearch). I have > the directory of the mp3s (System.IO.Directory.GetFiles). I want to > search the directory from the text in the textbox, adding to the > listbox if there is a match. I have tried > file.IndexOf(txtSearch.Text), file.Contains(txtSearch.Text), and > even InStr(file, txtSearch.Text). > > What am I missing? Is there an easier way to do this? I just want > to search for specific artists, songs, etc. This isn't hard... WHAT > IS GOING ON!!! heh. > > > Thanks, > > Josh > > Dim file As String > Dim mp3sPath As String = flbMp3s.Path > > If (txtSearch.Text <> "") Then > 'clear listbox > > flbMp3s.Items.Clear() > 'loading each file in working direcrtory of application > For Each file In > System.IO.Directory.GetFiles(flbMp3s.Path) > 'storing the filename into listbox items collection > If (InStr(file, txtSearch.Text) > 1) Then > flbMp3s.Items.Add(file) > End If > Next > End If Dim file As String Dim mp3sPath As String = flbMp3s.Path -> dim value as string = txtearch.text -> If value.length > 0 Then -> value = value.tolower 'clear listbox flbMp3s.Items.Clear() 'loading each file in working direcrtory of application For Each file In System.IO.Directory.GetFiles(flbMp3s.Path) 'storing the filename into listbox items collection -> If file.TOLOWER.indexof(value) > -1 Then flbMp3s.Items.Add(file) End If Next End If Don't know if this is the problem. Armin Either this is too easy or I completely missed your point...
Dim myPattern As String = "*christina*.mp3" Dim myFolder As String = "C:\MyMusic" For Each myFile As IO.FileInfo In (New IO.DirectoryInfo(myFolder)).GetFiles(myPattern) 'Fill listbox... Next Show quoteHide quote "Nonee" <N***@none.com> wrote in message news:ak8dt1l0r6mm5db833lg2kv7go7mqr89r6@4ax.com... > Ok ok... I have been staring at this for a generation or so now and it > is not working. And it is something really simple too. I have a > listbox of mp3s (flbMp3s). I have a textbox (txtSearch). I have the > directory of the mp3s (System.IO.Directory.GetFiles). I want to > search the directory from the text in the textbox, adding to the > listbox if there is a match. I have tried > file.IndexOf(txtSearch.Text), file.Contains(txtSearch.Text), and even > InStr(file, txtSearch.Text). > > What am I missing? Is there an easier way to do this? I just want to > search for specific artists, songs, etc. This isn't hard... WHAT IS > GOING ON!!! heh. > > > Thanks, > > Josh > > Dim file As String > Dim mp3sPath As String = flbMp3s.Path > > If (txtSearch.Text <> "") Then > 'clear listbox > > flbMp3s.Items.Clear() > 'loading each file in working direcrtory of application > For Each file In > System.IO.Directory.GetFiles(flbMp3s.Path) > 'storing the filename into listbox items collection > If (InStr(file, txtSearch.Text) > 1) Then > flbMp3s.Items.Add(file) > End If > Next > End If No, it is way too easy... Duh... *sigh*
Ever have one of those days??? Thank you... Show quoteHide quote On Tue, 24 Jan 2006 17:30:59 -0500, "Manuel" <NoM***@NoMailLand.com> wrote: >Either this is too easy or I completely missed your point... > >Dim myPattern As String = "*christina*.mp3" >Dim myFolder As String = "C:\MyMusic" >For Each myFile As IO.FileInfo In (New >IO.DirectoryInfo(myFolder)).GetFiles(myPattern) > 'Fill listbox... >Next > > >"Nonee" <N***@none.com> wrote in message >news:ak8dt1l0r6mm5db833lg2kv7go7mqr89r6@4ax.com... >> Ok ok... I have been staring at this for a generation or so now and it >> is not working. And it is something really simple too. I have a >> listbox of mp3s (flbMp3s). I have a textbox (txtSearch). I have the >> directory of the mp3s (System.IO.Directory.GetFiles). I want to >> search the directory from the text in the textbox, adding to the >> listbox if there is a match. I have tried >> file.IndexOf(txtSearch.Text), file.Contains(txtSearch.Text), and even >> InStr(file, txtSearch.Text). >> >> What am I missing? Is there an easier way to do this? I just want to >> search for specific artists, songs, etc. This isn't hard... WHAT IS >> GOING ON!!! heh. >> >> >> Thanks, >> >> Josh >> >> Dim file As String >> Dim mp3sPath As String = flbMp3s.Path >> >> If (txtSearch.Text <> "") Then >> 'clear listbox >> >> flbMp3s.Items.Clear() >> 'loading each file in working direcrtory of application >> For Each file In >> System.IO.Directory.GetFiles(flbMp3s.Path) >> 'storing the filename into listbox items collection >> If (InStr(file, txtSearch.Text) > 1) Then >> flbMp3s.Items.Add(file) >> End If >> Next >> End If >
Show Modal, then Again
Get associated icon for a file A question about finding class methods in the Help TopMost without SetFocus VB.NET profiler Assigning a Value to a Structure Pointed to by a Tag ? Listbox idiotic example progress bar right to left Importing XML File into an Empty Access Table Using a VB.net dll in VB6 |
|||||||||||||||||||||||