Counting number of files in dir

  • Thread starter Thread starter John J.
  • Start date Start date
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
 
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
 
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
 

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

Back
Top