truncated filename

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Quack Boy

    truncated filename

    Hi all,

    Is there an easy way to truncated the name of file name, say from
    " C:\my projects\dev\ba nana.txt" to just "banana.txt "
    Do you have to reverse the string and then count from the doit back to
    the slash or is there an easier way in VB 6? And go easy on me as I'm
    new to VB. :)

    Cheers
  • Rick Rothstein

    #2
    Re: truncated filename

    > Is there an easy way to truncated the name of file name, say from[color=blue]
    > " C:\my projects\dev\ba nana.txt" to just "banana.txt "
    > Do you have to reverse the string and then count from the doit back to
    > the slash or is there an easier way in VB 6? And go easy on me as I'm
    > new to VB. :)[/color]

    VB has an InStrRev function which does what the InStr function does, but
    in reverse (that is, it searches from the end of the text, not the
    beginning). Try this...

    FileName = "C:\my projects\dev\ba nana.txt"
    MsgBox Mid$(FileName, InStrRev(FileNa me, "\") + 1)

    Rick - MVP

    Comment

    • Quack Boy

      #3
      Re: truncated filename

      On Tue, 23 Nov 2004 10:24:52 -0500, "Rick Rothstein"
      <rickNOSPAMnews @NOSPAMcomcast. net> wrote:

      [color=blue]
      >
      > FileName = "C:\my projects\dev\ba nana.txt"
      > MsgBox Mid$(FileName, InStrRev(FileNa me, "\") + 1)
      >[/color]

      That'll be the quick way to do it. ;) Thank you, Rick.


      Comment

      Working...