how to check if file extension is member of filter list?

B

bart plessers

Hello,

I am developping a file browser bu use of internet explorer.

I am already so far that I get a full list of all the files of a selected
directory.
However, I only want to display certain files, i.e. pictures: jpg, gif, png,
tiff, etc...

So I want to set up a main variable, containing this "filter"

Now for every listed file, I want to check if its extension is listed in the
filter.

How can I achieve this without having an if-then for every extension?


tia

bartp




--

==========================================
Hyper A.R.T.
bart plessers
Paul Van Ostaijenlaan 4
3001 Heverlee
BELGIUM
tel: +32 (16) 23.40.85
fax: +32 (16) 23.41.06
==========================================
 
B

bart plessers

Yan,

that was what I was looking for!

will try it tomorrow. Maybe you can provide me with some sytax? How to build
the list? Is it just a string with all my extensions, separated by "," or
should I define some table?

tia

bartp

--

==========================================
Hyper A.R.T.
bart plessers
Paul Van Ostaijenlaan 4
3001 Heverlee
BELGIUM
tel: +32 (16) 23.40.85
fax: +32 (16) 23.41.06
==========================================
 
T

Tia

bart plessers said:
Hello,

I am developping a file browser bu use of internet explorer.

I am already so far that I get a full list of all the files of a selected
directory.
However, I only want to display certain files, i.e. pictures: jpg, gif, png,
tiff, etc...

So I want to set up a main variable, containing this "filter"

Now for every listed file, I want to check if its extension is listed in the
filter.

How can I achieve this without having an if-then for every extension?


Hi,
here is my preferred method:


'-------------------------------------------

AllowedExtensions = Array("asp", "csv", "doc", "htm")


For i = 0 To UBound(FileList)
If IsFileNameOK(FileList(i)) Then ' your code here
Next


Function IsFileNameOK(strFileSpec) 'Boolean
' Find the dot
DotPos = InStrRev(strFileSpec, ".")
If DotPos > 0 Then
' get the extension
strExtension = LCase(Right(strFileSpec, Len(strFileSpec) - DotPos))
' Loop through allowable extensions
For i = 0 To UBound(AllowedExtensions)
' Check for a match
If strExtension = LCase(AllowedExtensions(i)) Then
IsFileNameOK = True
Exit For
End If
Next ' i
End If ' dot found
End Function
 
B

bart plessers

thanx for code and your time!
Tomorrow I'll be on holliday, but surely give it a try afterwards!

bartp

--

==========================================
Hyper A.R.T.
bart plessers
Paul Van Ostaijenlaan 4
3001 Heverlee
BELGIUM
tel: +32 (16) 23.40.85
fax: +32 (16) 23.41.06
==========================================
 
B

bart plessers

thanx for code and your time!
Tomorrow I'll be on holliday, but surely give it a try afterwards!

bartp

--

==========================================
Hyper A.R.T.
bart plessers
Paul Van Ostaijenlaan 4
3001 Heverlee
BELGIUM
tel: +32 (16) 23.40.85
fax: +32 (16) 23.41.06
==========================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top