Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jan 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts

    finding last occurrence in a string

    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

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,045
    Thanks
    0
    Thanked 251 Times in 247 Posts
    Use InStrRev() (Instr Reverse) function.

  • #3
    New Coder
    Join Date
    Jan 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks. That should work. I'll give it a try.

  • #4
    New Coder
    Join Date
    Jan 2003
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It works like a charm. Thanks again.

    petela


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •