...

View Full Version : finding last occurrence in a string



petela
12-07-2004, 10:19 PM
Hi,

I know how to find the first occurrence of a character in a string using the VB
InStr function. How do I find the last occurrence of a character in a string? Here is the string I want to manipulate:

C:\Inetpub\wwwroot\greatnorthwest\web door gallery\entry and exterior\Entry w French side litesThumb.jpg

I want to find the position of the last occurrence of "\" in the string, and then trim everything to the left of it so that I the string is reduced to:

Entry w French side litesThumb.jpg.

How would I go about accomplishing this task? I have many more of these strings to manipulate, all contiaining different numbers of the "\" character, so I need to be able to work from right to left.

Thanks,
petela

glenngv
12-08-2004, 03:28 AM
Use InStrRev() (http://www.devguru.com/Technologies/vbscript/quickref/instrrev.html) (Instr Reverse) function.

petela
12-08-2004, 05:00 PM
Thanks. That should work. I'll give it a try.

petela
12-08-2004, 06:19 PM
It works like a charm. Thanks again.

petela



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum