Results 1 to 3 of 3

Thread: help brain freeze on mid / len / right

  1. #1

    Thread Starter
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492

    help brain freeze on mid / len / right

    I have say:

    C:\blah\foo\bar.txt

    I need just bar.txt...

    I see InStr returns first occurence..I probably need last occurence?

    Jon

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132
    Use InStrRev() to get last occurence of backslash and then Mid(... pos +1):
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim sText$
    3.  
    4.     sText = "C:\blah\foo\bar.txt"
    5.     MsgBox Mid(sText, InStrRev(sText, "\") + 1)
    6.  
    7. End Sub

  3. #3

Posting Permissions

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



Click Here to Expand Forum to Full Width