Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using "InstrRev"
Excel XP with Windows 2000
When I use the following: Dim strPath as String Dim lngSlash1 as Long strPath = "\\TEST1\TEST2\TEST3\TEST4\" lngSlash1 = InStrRev(argFullName, "\", -1, vbTextCompare) I would expect lngSlash1 to return 1 since the last character is a "\". However, the above function returns 26 for me. I thought "InStrRev" was supposed to return the position from the END of the string, not the beginning. Where am I going wrong? TIA. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using "InstrRev"
Please note that I failed to complete an edit in my OP:
argFullName should be changed to strPath in line 3. Sorry for the confusion. "quartz" wrote: Excel XP with Windows 2000 When I use the following: Dim strPath as String Dim lngSlash1 as Long strPath = "\\TEST1\TEST2\TEST3\TEST4\" lngSlash1 = InStrRev(argFullName, "\", -1, vbTextCompare) I would expect lngSlash1 to return 1 since the last character is a "\". However, the above function returns 26 for me. I thought "InStrRev" was supposed to return the position from the END of the string, not the beginning. Where am I going wrong? TIA. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using "InstrRev"
What you're seeing is the designed behaviour. Position from start of string,
searching from end of string. You could subtract that number from Len(argFullName) to get the number you want. -- Rob van Gelder - http://www.vangelder.co.nz/excel "quartz" wrote in message ... Please note that I failed to complete an edit in my OP: argFullName should be changed to strPath in line 3. Sorry for the confusion. "quartz" wrote: Excel XP with Windows 2000 When I use the following: Dim strPath as String Dim lngSlash1 as Long strPath = "\\TEST1\TEST2\TEST3\TEST4\" lngSlash1 = InStrRev(argFullName, "\", -1, vbTextCompare) I would expect lngSlash1 to return 1 since the last character is a "\". However, the above function returns 26 for me. I thought "InStrRev" was supposed to return the position from the END of the string, not the beginning. Where am I going wrong? TIA. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
correct syntax for nesting "if", "and", and "vlookup"....if possib | Excel Worksheet Functions | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
change "true" and "false" to "availble" and "out of stock" | Excel Worksheet Functions | |||
HELP on "left","right","find","len","substitute" functions | Excel Discussion (Misc queries) | |||
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next | New Users to Excel |