SQL_Hell
SQL Server DBA
- Local time
- Today, 23:31
- Joined
- Dec 4, 2003
- Messages
- 1,361
Hey all,
I am writing a DTS package to process a number of excel files and I need some help with the VBscript part of it.
I want to take parts of the file name to use in a variable, the files names look like this:
x_Choc_1999_0106.csv
x_Cocoa_2007_0112.csv
I am only interested in whether its Choc or Cocoa, so I have the following code to achieve the required result:
FOR each fil in fold.Files
file = strReverse(fil.name)
file = MID (file,Instr(file,"_")+1)
file = mid (file,Instr(file,"_")+1)
file = strReverse(file)
file = mid (file,Instr(file,"_")+1)
'msgbox "" & file
This code works ok but it just doesn't seem very nicely coded, a bit clunky.
Is there a better way I can achieve this?
I am writing a DTS package to process a number of excel files and I need some help with the VBscript part of it.
I want to take parts of the file name to use in a variable, the files names look like this:
x_Choc_1999_0106.csv
x_Cocoa_2007_0112.csv
I am only interested in whether its Choc or Cocoa, so I have the following code to achieve the required result:
FOR each fil in fold.Files
file = strReverse(fil.name)
file = MID (file,Instr(file,"_")+1)
file = mid (file,Instr(file,"_")+1)
file = strReverse(file)
file = mid (file,Instr(file,"_")+1)
'msgbox "" & file
This code works ok but it just doesn't seem very nicely coded, a bit clunky.
Is there a better way I can achieve this?