Home All Groups Group Topic Archive Search About

DUMB question about IndexOf

Author
24 Jan 2006 10:00 PM
Nonee
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

Author
24 Jan 2006 10:27 PM
Armin Zingler
Show quote Hide quote
"Nonee" <N***@none.com> schrieb
> 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


Maybe it's because an "A" is not an "a"?


        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
Author
24 Jan 2006 10:30 PM
Manuel
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
Author
25 Jan 2006 12:19 AM
Nonee
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
>