1 Replies - 209 Views - Last Post: 07 December 2012 - 04:20 PM Rate Topic: -----

#1 VBMyHero  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 07-December 12

Problem using loop to find latest revision level of file

Posted 07 December 2012 - 03:46 PM

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!

Is This A Good Question/Topic? 0
  • +

Replies To: Problem using loop to find latest revision level of file

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1043
  • View blog
  • Posts: 4,054
  • Joined: 02-July 08

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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1