I'm (obviously a novice) writing a program in VB 2010 Express that goes out onto our local server, through several directories, finds a specific excel file, opens it, and assigns specific cell values to variables for use later in code. I don't need help building the path string to navigate the directories - I've actually figured that out.
We have a standard naming convention for the excel file, which would look like this: 12345R0.dat.xls, where "12345" is a manufacturing job number and "R0, 1, 2, 3, etc." is the revision level. Only the latest revision of this file resides in this directory.
I've been sucessful in accessing the file through hard-coding the path, but I need my program to look into the directory and find the ".dat.xls" file regardless of the revision level. The file I need isn't the only .xls file in the directory, but it's the only ".dat.xls".
Is there a way to ignore the "R" and any integer after it, and open the file based only the .dat.xls extension? Sorry if I gave too much info for a simple question.
Oops - I changed the approach of my question after typing the subject, so I doesn't really match. Sorry again!
1 Replies - 319 Views - Last Post: 07 December 2012 - 04:20 PM
Replies To: Problem using loop to find latest revision level of file
Re: Problem using loop to find latest revision level of file
Posted 07 December 2012 - 04:20 PM
You need to use string manipulation and create a string that starts after the 'R' and not farther than the '.' . Two integers/indexes If you check each string for the IndexOf("R")+1 and IndexOf(".") and then make a Substring(firstIndex, secondIndex) you will have your match.
Page 1 of 1