Re: Common Dialog - Change file extension

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



> >>> >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


.



Relevant Pages

  • Re: Common Dialog - Change file extension
    ... > Drink the coffee - we've been down this lane before ... Function ExtractFileExtension(Fle As String) As String ...
    (microsoft.public.vb.general.discussion)
  • Re: OT - What wouldnt you give up?
    ... Our well is supposed to be okay to drink, but it tastes terrible to me. ... My dogs have to have their treats. ... kitchen sink where you use water to cook, ... I don't like Starbuck's coffee. ...
    (sci.med.transcription)
  • Re: EXCOMMUNICATION - What are the reasons?
    ... That inasmuch as any man drinketh wine or strong drink among you, ... other evils can result from unwise use of alcohol and tobacco, ... hot coffee from McDonald's and spill it on themselves. ... We oppose the use of illegal drugs, because we can see what their use does ...
    (soc.religion.mormon)
  • Re: assembly language and reverse engineering
    ... just be to prevent me from quantifying his personality. ... intuition usually is. ... attempted to reduce the large quantities of chocolate, coffee, and pop he ... so, usually over most of the day, wheras my dad will often drink large 1/2 ...
    (alt.lang.asm)
  • Re: TR: My practically perfect Disney day
    ... I woke early at the Beach Club, showered, made coffee in my in-room ... favorite drink. ... Great Movie Ride, big droplets were splatting on the sidewalk, so I ... boat ride back to the Beach Club for a bit of Japanese TV before bed. ...
    (rec.arts.disney.parks)