Using "InstrRev"

G

Guest

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.
 
G

Guest

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.
 
R

Rob van Gelder

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top