473,396 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

search within a arraylist

I've open a file and read the file into arraylist. My text file contents are

a.txt=a.bat
b.txt=b.bat
c.txt=c.bat

i want to do a select case statement for filewatcher, if a.txt is created,
execute a.bat and etc etc I do not wish to hard-code all possible *.txt file
in my select case statements ...i thought of the script below. Pls advise
syntax

***********************************************
dim myitem as new arraylist
'open a file, and stored into array.
myitem.add(lines)

Private Sub FileSystemWatcher1_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Created

select case e.name
'this is normally what i do
case "a.txt"
process.start("a.bat")

'say if c.txt file is created, how can i do a search into my
arraylist and then execute the batch file ?
'i do not wish to hard-code it for every text files.

case substr(myitems) or case instr(myitems) ...i m stuck here
end sub
Jan 20 '06 #1
3 1201
James,

As I understand you well than you need an for index loop

Something as quickly typed.

\\\
dim i as integer
for i from 0 to myarraylist.lenght - 1
if myarraylist(i).ToString = myfileText then
exit for
next
dim whatIwantIsIn as string = myarraylist(i)
///

I hope this helps,

Cor
Jan 20 '06 #2
"Cor Ligthert [MVP]" <no************@planet.nl> schrieb:
As I understand you well than you need an for index loop

Something as quickly typed.

\\\
dim i as integer
for i from 0 to myarraylist.lenght - 1
if myarraylist(i).ToString = myfileText then
exit for
next
dim whatIwantIsIn as string = myarraylist(i)
///


Mhm... Why not use 'ArrayList.IndexOf' or 'ArrayList.BinarySearch' if the
list is already sorted?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 20 '06 #3
> "Cor Ligthert [MVP]" <no************@planet.nl> schrieb:
As I understand you well than you need an for index loop

Something as quickly typed.

\\\
dim i as integer
for i from 0 to myarraylist.lenght - 1
if myarraylist(i).ToString = myfileText then
exit for
next
dim whatIwantIsIn as string = myarraylist(i)
///


Mhm... Why not use 'ArrayList.IndexOf' or 'ArrayList.BinarySearch' if the
list is already sorted?

Because I all the time was thinking "There is a better way I know it",
however I have no brainconnector, so I could not find it.

:-)

Cor
Jan 20 '06 #4

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

Similar topics

8
by: Sek | last post by:
Folks, I have an ArrayList of integers. I have sorted the list already. Now, i want to find the index of the first element that is greater than a given number. How to accomplish this in C#?
1
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and...
10
by: JohnR | last post by:
I have an arraylist of string values. I would like to search the arraylist to find the index of a particular string and I would like the search to be case insensitive. dim al as new arraylist...
6
by: John Veldthuis | last post by:
I have an ArrayList set up with a set of class objects. The class has 3 strings in it and are as follows ProdID GSP Description Okay now problem with getting all these into the list and...
11
by: Simon Says | last post by:
Hi all, I've an arraylist A1 that contains {0,1,2,3,4,5,9,8,7} I've another arraylist A2 that contains {4,5,9} I would like to search whether if A2 is present in A1 and maybe return the first...
4
by: Jon | last post by:
Hi, I have an arrayList that holds an ArrayObject with (Qty & ItemCode). e.g. arrayList.Add(New ArrayObject(Qty, ItemCode) However, I want to search the arrayList and check if the ItemCode...
0
by: Eugene Anthony | last post by:
BlogListingAll.aspx ------------------- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="user_BlogListingAll.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML...
1
by: Ken Fine | last post by:
I have set up Microsoft Search Server 2008 Express. I want to know how I can query against it and return results in a form that can be bound to ASP.NET controls like ListViews. If there's simply...
0
by: TheClouds | last post by:
Hi everyone This program is using A* search and it supposed to find the shortest path for Pacman in the program as(px,py) or currentCell to catch the ghost in the program as(gx,gy)or goalCell.for...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.