![]() |
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. |
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. |
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. |
All times are GMT +1. The time now is 11:44 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com