473,417 Members | 1,554 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,417 software developers and data experts.

select ..case ...hardcoding ?

i wrote a filewatcher application and inside the code, i've a select case
statement :
Private Sub FileSystemWatcher1_Created(ByVal sender As Object, ByVal e As
System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Created

Select Case UCase(e.Name)
Case "mytest.txt"
Process.Start("Encryption.bat")
EventLog1.WriteEntry("Filename " & e.Name & " created.")
Case "mytest1.txt"
Process.Start("Encryption1.bat")
EventLog1.WriteEntry("Filename " & e.Name & " created.")
End Select

end sub

this work because my user has informed me earlier what are the possible
filenames. However i would like to improve the code further such that i
don't want to hard-code filenames into my application. I created a
masterlist.txt file and my application read the file (streamreader) as
follows :

masterlist.txt
========
;allows user to flexibly put in any files to watch and execute the batch
file accordingly
mytest.txt=encryption.bat
mytest1.txt=encryption1.bat

After reading it into different variables (how do i split into an array ?) ,
does anyone know the ALTERNATIVE SELECT-CASE codes to write such that when
mytest.txt appears, filewatcher will execute encryption.bat and other batch
files respectively ?

Eg

if mytest.txt = true then process.start("encryption.bat") ?

or something of this nature ?

if array(1) = true then process.start array(1.1)
if array(2) = true then process.start array(2.1)


Nov 23 '05 #1
2 1277
James wrote:
Select Case UCase(e.Name)
Case "mytest.txt"
UCase...."mytest.txt".... can you see a potential problem there?
I created a masterlist.txt file and my application read the file
(streamreader) as follows After reading it into different variables (how
do i split into an array ?) ,


What parts of "it" do you read into "different variables"? What is the "it"
you want to split() into an array?

Andrew
Nov 23 '05 #2
"James" <jk****@hotmail.com> wrote in message
news:OH**************@TK2MSFTNGP09.phx.gbl...

[snip]
masterlist.txt
========
;allows user to flexibly put in any files to watch and execute the batch
file accordingly
mytest.txt=encryption.bat
mytest1.txt=encryption1.bat

After reading it into different variables (how do i split into an array ?)

,

Split()

Example code for a button using it:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles Button1.Click
'Test string can be replaced:
Dim myString As String = "mytest.txt=encryption.bat"

'Split string into an array (Without the "=")
Dim myArray() As String = Split(myString, "=")

'Get total of entries in array... because I can...
'If your gonna use this variable then it should be in a module as
public
' It would then be used as: myArrayCount = myArray.Length
Dim myArrayCount As Integer = myArray.Length

MsgBox(myArray(0).ToString + vbCrLf + myArray(1).ToString + vbCrLf _
+ "Total records: " + myArrayCount.ToString, MsgBoxStyle.OKOnly, _
"Example")
End Sub
Nov 23 '05 #3

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

Similar topics

1
by: AngryGerbil | last post by:
hey, How do I acquire MethodInfo WITHOUT hardcoding method name as a string?!??!The fact I have to use xxx.Gettype.GetMethod("MyMethod", xxx) is making me want to drive an ice pick into my eye! I...
10
by: MLH | last post by:
Suppose the following... Dim A as Date A=#7/24/2005# I wish to compare value of A against 2 other values: 1) 8/1/2005 2) 9/1/2005 Which is better and why... First:
7
by: Lauren Quantrell | last post by:
Is there any speed/resource advantage/disadvantage in using Select Case x Case 1 Case 2 etc. many more cases... End Select VS.
8
by: AngryGerbil | last post by:
hey, How do I acquire MethodInfo WITHOUT hardcoding method name as a string?!??!The fact I have to use xxx.Gettype.GetMethod("MyMethod", xxx) is making me want to drive an ice pick into my eye! I...
1
by: microsoft.public.dotnet.languages.vb | last post by:
Hi All, I wanted to know whether this is possible to use multiple variables to use in the select case statement such as follows: select case dWarrExpDateMonth, dRetailDateMonth case...
1
by: =?Utf-8?B?d2VzdGNvYXN0Y29kZQ==?= | last post by:
void CreateBatches(string currDir, DataTable hvTable) { string id; DirectoryInfo di = new DirectoryInfo(currDir); StreamWriter writer = new StreamWriter(currDir + "\\Index.dat", false); DataRow...
3
by: marexposed | last post by:
I've got this error (see the path in last line) db=MySQLdb.connect(host='localhost',use_unicode = True, charset = "Windows-1251",user='root',passwd='12',db='articulos') File...
0
by: Gabriel Genellina | last post by:
En Thu, 17 Apr 2008 15:41:49 -0300, <marexposed@googlemail.comescribió: Looks like a configuration problem in MySQL itself, unrelated to Python. See the my.ini file in MySQL installation...
2
Plater
by: Plater | last post by:
So this is kind of an odd request. I want to be able to return a small "hardcoded" dataset from a stored procedure. Is that even possible? I want for example a "GetAvailableTypes" store procedure...
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?
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
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,...
0
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,...
0
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: 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...

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.