473,471 Members | 1,744 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DUMB question about IndexOf

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
Jan 24 '06 #1
3 1150
"Nonee" <No**@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
Jan 24 '06 #2
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" <No**@none.com> wrote in message
news:ak********************************@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

Jan 24 '06 #3
No, it is way too easy... Duh... *sigh*

Ever have one of those days???

Thank you...
On Tue, 24 Jan 2006 17:30:59 -0500, "Manuel" <No****@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" <No**@none.com> wrote in message
news:ak********************************@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


Jan 25 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Greener | last post by:
May I ask you the following? Two questions about the following block of code: 1) How to open the file in NON-ReadOnly mode? I tried many things, but none of them was working. 2) Any problems...
7
by: Gui Lloyd | last post by:
I have a problem with performance in IE. The script above works quite fine when the table has a small number of elements, but, when the table has 2500 elements, when I click in the checkbox of the...
3
by: Barry Mossman | last post by:
Hi, I get the feeling that I am missing something with regards to casting. The CopyTo method allows me to copy the contents of a collection into an array. My collection is a MatchCollection...
3
by: Eeediot | last post by:
I am trying to write code that will go through the existing list items in a listbox and perform a string comparision with a supplied string. That particular item will automatically selected if...
35
by: Cor | last post by:
Hallo, I have promised Jay B yesterday to do some tests. The subject was a string evaluation that Jon had send in. Jay B was in doubt what was better because there was a discussion in the C#...
2
by: kd | last post by:
Hi All, Consider the following code. Dim str As String Dim i As Integer str = " Hello Hi" If str.IndexOf("Abc Def") Or str.IndexOf("Ghi jkl mno") Or _ str.IndexOf("pqr stu vwxe") Or...
18
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the...
16
by: CMM | last post by:
Is it me or has anyone noticed that F1 is really dumb in VS2005. Since VB3 I have been able to click F1 on an ambiguous method in code and the IDE automatically determines the type based on the...
8
by: SMJT | last post by:
Does anyone know why the string contains function always returns true if the token is an empty string? I expected it to return false. "AnyOldText".Contains("") or...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.