Counting number of files in dir

J

John J.

Hi,

I'm looking for a procedure which counts the number of files in a directory.
Can someone explain how this can be done?

Thanks very much for your help.
JJ
 
J

John J.

Thank you very much!

Steve said:
Dim I As Integer
Dim Path As String
Path = "FullPathOfYourDirectory"
If Dir(Path,vbDirectory) <> "" Then
I = 1
Else
I = 0
GoTo ExitHere
End If
Do Until Dir = ""
If Dir() <> "" Then
I = I + 1
End If
Loop
ExitHere:
MsgBox "There Are " & I & " Files In The Directory"

Steve
 
L

Larry Linson

John J. said:
I'm looking for a procedure which counts the
number of files in a directory. Can someone
explain how this can be done?

Check Help on the Dir command. It can be used to cycle through all files in
a folder. Directories went away with 16-bit Windows, didn't they?

Larry Linson
Microsoft Office Access MVP
 
Top