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

Counting Files in a folder?

Status
Not open for further replies.

pielz

Programmer
Nov 12, 2002
8
US
Is it possible for me to count how many files are in a folder? If so how. Thanks for your time.
 
Private Sub Command1_Click()
MsgBox NumOfFiles("C:\Test\") & " files in C:\Test\"
End Sub

Function NumOfFiles(Path As String) As Long
Dim MyFile As String
Dim Counter As Long
MyFile = Dir(Path & "*.*")
Do While MyFile <> vbNullString
MyFile = Dir
Counter = Counter + 1
Loop
NumOfFiles = Counter
End Function Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top