Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

substrings 2

Status
Not open for further replies.

sweetleaf

Programmer
Jan 16, 2001
439
CA
Hi

How do I find the last occurence of a charachter or symbol in a given string:

ie. how would i find the position of the second "\" in the following string?
"C:\stuff\pk_promo8_feb12_afternoon.txt"

Thanks,
Mark
 
Mark:

Try the function InStrRev.

s = "C:\stuff\pk_promo8_feb12_afternoon.txt"

position = InStrRev(s,"\")

msgbox position

Parke
 
And from the other side: ;-)

test = "C:\stuff\pk_promo8_feb12_afternoon.txt"
nFirst = InStr(test, "\")
if nFirst<>0 then nSecond = InStr(nFirst+1, test, &quot;\&quot;)
if nSecond<> 0 then Response.Write nSecond

br
Gerard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top