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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to use the DIR command

Status
Not open for further replies.

zgrande

Programmer
Mar 18, 2002
15
0
0
BR
Hi,
I want to list diferente kind of files in a directory, for example *.txt,*.zip,... But I want to know if I can do it just once, instead of call the DIR function for each extension
 
You might something like the following:

lStr_CheckFile = Dir(<Your Direcotry>, vbDirectory)

Do While (Len(lStr_CheckFile) > 0)
lStr_CheckFile = UCase(lStr_CheckFile)
If (lStr_CheckFile <> &quot;PAGEFILE.SYS&quot;) Then
If (Left(lStr_CheckFile, 1) <> &quot;.&quot;) Then
lInt_FileType = GetAttr(<Your Direcotry> & lStr_CheckFile) And vbDirectory
If (Int_FileType <> vbDirectory) Then
Select Case Right(lStr_CheckFile, 4)
Case &quot;.ZIP&quot;
<Handle Zip File>
Case &quot;.TXT&quot;
<Handle Text File>
...
End Select
End If
End If
End If
lStr_CheckFile = Dir
Loop

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top