OK, so this is basically an operator precedence issue that hopefully someone could explain to me. I want to add the following code to my login script to assist in mapping drives.
strDrive = Chr(Asc(Left(strDrive,1)-1)) & ":"
strDrive initially holds a 2 char string containing a drive letter and a colon (i.e. "W:"). The idea here is to pull just the drive letter from the string, convert that letter into its ascii code, subtract 1 from that value, convert that back into a character and finally append the colon back to it. After all this strDrive should contain "V:" but I get a type mismatch error when running the script. If I break the line out and read each step into a variable as below, it works.
strLetter = Left(strDrive,1)
strAscii = Asc(strLetter) -1
strNextLetter = Chr(strAscii)
strDrive = strNextLetter & ":"
I'm sure this has something to do with the order of operation and at this point I'm just being stubborn. Is there a way to accomplish this in a single line of code?
strDrive = Chr(Asc(Left(strDrive,1)-1)) & ":"
strDrive initially holds a 2 char string containing a drive letter and a colon (i.e. "W:"). The idea here is to pull just the drive letter from the string, convert that letter into its ascii code, subtract 1 from that value, convert that back into a character and finally append the colon back to it. After all this strDrive should contain "V:" but I get a type mismatch error when running the script. If I break the line out and read each step into a variable as below, it works.
strLetter = Left(strDrive,1)
strAscii = Asc(strLetter) -1
strNextLetter = Chr(strAscii)
strDrive = strNextLetter & ":"
I'm sure this has something to do with the order of operation and at this point I'm just being stubborn. Is there a way to accomplish this in a single line of code?