Since you have only a few extensions, I would probably imbed the check into the code like:
Files = Dir(App.Path & "\*.*"
Do Until Len(Files) = 0
FileName = LCase(Files)
If InStr(1, FileName, ".bmp" > 0 _
Or InStr(1, FileName, ".gif" > 0 _
Or InStr(1, FileName, ".jpg" > 0 Then
If MsgBox(Files, vbOKCancel) = vbCancel Then
Exit Do
End If
End If
Files = Dir
Loop
This is not a very elegant solution. For something more dynamic, you could maintain an array or a listbox of extensions you want to select then write a function to check whether the filename passes this filter.
Thanks Kmomberg, just in case ... i did found this way out
Filename = Dir(App.Path & "\*.*"
Do Until Len(Filename) = 0
'get file extension
For n = Len(Filename) To (Len(Filename) - 2) Step -1
ext = Mid(Filename, n, 3)
Next n
Dir=Filename
msgbox (ext)
Loop
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.