Re: Common Dialog - Change file extension
- From: "Rick Rothstein [MVP - Visual Basic]" <rickNOSPAMnews@xxxxxxxxxxxxxxxxx>
- Date: Wed, 10 Aug 2005 12:14:38 -0400
> >>> >Why has nobody mentioned InstrRev to find the dot before the
> >>extension? It
> >>> >has to be the easiest non-API method.
> >>>
> >>> </snip>
> >>>
> >>> InsStrRev is not safe '\' and ':' are ignored
> >>>
> >>> A painful lesson - but I learned it.
> >>
> >>I know it is relatively early here and I haven't had my morning
coffee
> >>yet<g>, but I am not clear what you mean by this. What do you mean
by
> >>InStrRev ignores "\" and ":"?
> >
> > Drink the coffee - we've been down this lane before
> >
> > c:\some.dir\somefile
> >
> > Purely for posterity - can't leave misinformation lurking around <g>
>
> What is the problem?
>
> InstrRev("c:\some.dir\somefile", "\") = 12
> InstrRev("c:\some.dir\somefile", ":") = 2
>
> Looks OK to me
It is not that InStrRev can't find those symbols... the problem is only
looking for "." can return an non-extension if the only 'dot' in a path
is on the 'wrong' side of the backslash character. Using the posted
example and suggested InStrRev function...
FileNamePath = "c:\some.dir\somefile""
Debug.Print Mid$(FileNamePath, InStrRev(FileNamePath, ".") + 1)
will print out
dir\somefile
as the extension.
Rick
.
- References:
- Common Dialog - Change file extension
- From: Elmo Watson
- Re: Common Dialog - Change file extension
- From: Al Reid
- Re: Common Dialog - Change file extension
- From: Dave
- Re: Common Dialog - Change file extension
- From: J French
- Re: Common Dialog - Change file extension
- From: Rick Rothstein [MVP - Visual Basic]
- Re: Common Dialog - Change file extension
- From: J French
- Re: Common Dialog - Change file extension
- From: Dave
- Common Dialog - Change file extension
- Prev by Date: Re: Common Dialog - Change file extension
- Next by Date: Re: Printer.Font.Name funnies
- Previous by thread: Re: Common Dialog - Change file extension
- Next by thread: Re: Common Dialog - Change file extension
- Index(es):
Relevant Pages
|