Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering a List of Files

Status
Not open for further replies.

KingofSnake

Programmer
Jul 25, 2000
73
US
What I want to do is to get a list of files from a specified directory. I want this list to only pick up certain files, for example: *.jpg, *.gif, and *.bmp. How could this be done? I was using the Dir function, but it won't let me use all three filters.
KingOfSnake - The only sports drink with ice crystals
(and marshmellos!)
 
Isn't there some way to do this?
KingOfSnake - The only sports drink with ice crystals
(and marshmellos!)
 
Try this . . .

Code:
dim strFileName as string

strFileName = dir$("C:\*.jpg")

Do while len(trim$(strFileName)) > 0 
    Debug.print strFileName 
    strFileName = Dir$
Loop

Of course, you can specify whatever path you want (I used 'C:\') and whatever file extention you want (I used .jpg). Hope this works for you!



- Jeff Marler B-)
 
Actually, I wanted more than just one filter. But I figured it out, I can't belive I didn't see it before.

All I needed to do was to do multiple dir's in a loop, and add the results in an array. *Hits head*

But thanks anyway.

KingOfSnake - The only sports drink with ice crystals
(and marshmellos!)
 
Yeap! For multiple filter types, that is exactly what I would've done as well! ;-)

- Jeff Marler B-)
 
Search for my FolderView on It uses fast API to return multiple files. The code is in Vb6 and uses Split to return array of filespecs. It then loops thru API's which is much faster than Dir$ and it returns much more info.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top