473,803 Members | 3,356 Online
Bytes | Software Development & Data Engineering Community
+ 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.Dire ctory.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(tx tSearch.Text), file.Contains(t xtSearch.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.C lear()
'loading each file in working direcrtory of application
For Each file In
System.IO.Direc tory.GetFiles(f lbMp3s.Path)
'storing the filename into listbox items collection
If (InStr(file, txtSearch.Text) > 1) Then
flbMp3s.Items.A dd(file)
End If
Next
End If
Jan 24 '06 #1
3 1165
"Nonee" <No**@none.co m> 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.Dire ctory.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(tx tSearch.Text), file.Contains(t xtSearch.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.C lear()
'loading each file in working direcrtory of application
For Each file In
System.IO.Direc tory.GetFiles(f lbMp3s.Path)
'storing the filename into listbox items collection
If (InStr(file, txtSearch.Text) > 1) Then
flbMp3s.Items.A dd(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.C lear()
'loading each file in working direcrtory of application
For Each file In System.IO.Direc tory.GetFiles(f lbMp3s.Path)
'storing the filename into listbox items collection
-> If file.TOLOWER.in dexof(value) > -1 Then
flbMp3s.Items.A dd(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*.mp 3"
Dim myFolder As String = "C:\MyMusic "
For Each myFile As IO.FileInfo In (New
IO.DirectoryInf o(myFolder)).Ge tFiles(myPatter n)
'Fill listbox...
Next
"Nonee" <No**@none.co m> wrote in message
news:ak******** *************** *********@4ax.c om...
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.Dire ctory.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(tx tSearch.Text), file.Contains(t xtSearch.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.C lear()
'loading each file in working direcrtory of application
For Each file In
System.IO.Direc tory.GetFiles(f lbMp3s.Path)
'storing the filename into listbox items collection
If (InStr(file, txtSearch.Text) > 1) Then
flbMp3s.Items.A dd(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****@NoMailL and.com>
wrote:
Either this is too easy or I completely missed your point...

Dim myPattern As String = "*christina*.mp 3"
Dim myFolder As String = "C:\MyMusic "
For Each myFile As IO.FileInfo In (New
IO.DirectoryIn fo(myFolder)).G etFiles(myPatte rn)
'Fill listbox...
Next
"Nonee" <No**@none.co m> 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.Dire ctory.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(tx tSearch.Text), file.Contains(t xtSearch.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.C lear()
'loading each file in working direcrtory of application
For Each file In
System.IO.Direc tory.GetFiles(f lbMp3s.Path)
'storing the filename into listbox items collection
If (InStr(file, txtSearch.Text) > 1) Then
flbMp3s.Items.A dd(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
2077
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 with the lines with document.write (...), as indicated below?
7
2147
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 table header (to select all the checkboxes in table), the script demands at least 3 minutes to execute. I tested the same script in Mozilla and the response time is much more faster. Does anyone has an idea? <script> function...
3
1567
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 produced by Regex. The Collection's entries are all valid strings. If I CopyTo to a string array it compiles ok, but fails at run time with an InvalidCastException. It works if I CopyTo an object array. ... does this mean that the MatchCollection's...
3
1498
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 there is a match. I am trying to use the IndexOf method to accomplish this task but, alas, I have been unsuccessful. If anyone has any ideas or suggestions it would be much appreciated. Yes, I am a newbie to ASP.NET. Yes, I am a newbie to...
35
2588
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# newsgroup on 25 September. The regular expressions where in that newsgroup too involved. I told yesterday night, to Jay that I would test all 4 methods and the stupid method I was thinking of the first time that night when I saw Jon's
2
4223
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 str.IndexOf("errr erttt. tttt") Or _
18
4752
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 class where only the "searched" property has a value. I expected to get the index into the arraylist where I could then get the entire class instance. However, the 'indexof' is never calling my overloaded, overrides Equals method. Here is the...
16
1653
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 code itself and shows the right help topic. This even worked more or less in VS2003. But in VS2005, if I highlight the "Host" method below and hit F1 I get a help topic on the "UriBuilder.Host" property. Huh????? That's dumb. Dim o as New...
8
4664
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 "AnyOldText".Contains(String.Empty)
0
9703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10300
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9127
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5503
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4277
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 we have to send another system
3
2974
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.