Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
'add reference to Microsoft Scripting Runtime
Private Sub main()
MsgBox CountFiles("c:\")
MsgBox CountFiles("c:\", "txt")
End Sub
Private Function CountFiles(ByVal folderPath As String, Optional ByVal fileType As String = "*")
Dim oFSO As New FileSystemObject
Dim oFolder As Folder
Dim oFiles As Files
Dim oFile As File
Dim count As Long
Set oFolder = oFSO.GetFolder("c:\")
Set oFiles = oFolder.Files
fileType = LCase(Trim(fileType))
If fileType = "*" Then
CountFiles = oFiles.count
Else
For Each oFile In oFiles
If LCase(oFSO.GetExtensionName(oFile.Name)) = fileType Then count = count + 1
Next oFile
CountFiles = count
End If
End Function
Dim strFiles As String
Dim lngCount As Long
strFiles = Dir("c:\*.doc")
Do Until Len(strFiles) = 0
strFiles = Dir
lngCount = lngCount + 1
Loop
MsgBox lngCount & " Files"