UCase filename extension with 3 and 4 characters

  • Thread starter Thread starter Bradley C. Hammerstrom
  • Start date Start date
B

Bradley C. Hammerstrom

A2K,

I have a Sub ReadFolderInfo containing the following lines:

Types = UCase(right(FileName, 3))
Select Case Types
Case "jpg", "jpeg"

It doesn't find the 4-character extension files ("jpeg")--only the files
with 3 ("jpg").

How can I change it to also catch the case when the file extension is 4
characters long?

Brad H.
 
Bradley C. Hammerstrom said:
A2K,

I have a Sub ReadFolderInfo containing the following lines:

Types = UCase(right(FileName, 3))
Select Case Types
Case "jpg", "jpeg"

It doesn't find the 4-character extension files ("jpeg")--only the
files with 3 ("jpg").

How can I change it to also catch the case when the file extension is
4 characters long?

Brad H.

There are several ways to split out the extension based on the location
of the last "." in FileName. Here's one:

Dim lngX As Long

lngX = InStrRev(FileName, ".")
If lngX = 0 Then
Types = "" ' no extension
Else
Types = Mid(FileName, lngX + 1)
End If
 
Back
Top