|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
search within a arraylista.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 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 "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb: Mhm... Why not use 'ArrayList.IndexOf' or 'ArrayList.BinarySearch' if the > 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) > /// list is already sorted? -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
Show quote
Hide quote
> "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb: Because I all the time was thinking "There is a better way I know it", >> 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? > however I have no brainconnector, so I could not find it. :-) Cor
Refresh questions
installing my app on another computer Question on finding records in a ado.net vb dataset ConnectionString property has not been initialized memeory release from un managed code installing an icon in the all users startup folder Retrieving file info from ftp server Need to find which text box has the focus. wince, datagrid... no define >< [OT] We have a winner! |
|||||||||||||||||||||||