Link to home
Start Free TrialLog in
Avatar of sirbounty
sirbountyFlag for United States of America

asked on

visual studio 2010 - reference question

Within my app, I am receiving a string containing a folder path.
Within that path, there will be a number from 1 to 6 .  I have been determining the number's position by splitting the string on the "\" character - so far, it has always been in the 3rd element (though I can adjust my logic if that changes at some point).
My dilema is, I need to convert that number to a letter (1=H, 2=I, etc...6=M).
So I'd like to know what options I have to approach this.
My app needs to run a shelled process that needs the local volume, which is indicated by the numeric value in the string.
Looking for suggestions - thanks!
Avatar of choedanKal
choedanKal

im not sure i got you correctly, but if you start from 'H' than : Convert.ToInt32(char - 'G')
Avatar of sirbounty

ASKER

Hmm - not following that route.

Here's what I'm currently using in my function...was looking for something perhaps a bit more efficient:

  Dim ServerName As String
  Select Case FolderPath.Split("\")(3).Substring(FolderPath.Split("\")(3).Length - 2, 1)
     Case 1 ' = H
         ServerName = FolderPath.Split("\")(2).ToUpper
         FolderPath = "H:\Data" & FolderPath.Substring(FolderPath.IndexOf("\", 3)).Replace("_1$", "")
         

Open in new window

That puts FolderPath in a usuable format.  FolderPath value will be one of two path combinations, but the above works for both (i.e. something like \\server\datashare_1$\ or \\server\archiveshare_1$)
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I get where you're going with that, but ended up having to use chr(71+drive) - 47 was coming up as "/", and the resulting chr(48) was "0".
Also modified the replace function to read in the drive variable instead of the numeric constant.

At any rate, that should do it - thanks!
Glad to help. I saw 47 which was in hex column which I did not realize. H is 72.