View Full Version : finding last occurrence in a string

12-07-2004, 09:19 PM

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.


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

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

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


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum