Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 441
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 441
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
correct syntax for nesting "if", "and", and "vlookup"....if possib Christine Excel Worksheet Functions 4 January 2nd 09 10:43 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
HELP on "left","right","find","len","substitute" functions serene83 Excel Discussion (Misc queries) 5 June 27th 06 02:23 AM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM


All times are GMT +1. The time now is 11:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"