I need some code that will count the # of files in a directory.
If u can help it would be appreciated.
Lee S
Printable View
I need some code that will count the # of files in a directory.
If u can help it would be appreciated.
Lee S
Add a reference the the Microsoft Scripting Runtime and paste the code in form load:
private Sub Form_Load()
Dim fso as FileSystemObject
Dim oFolder as Scripting.Folder
set fso = new Scripting.FileSystemObject
set oFolder = fso.GetFolder("C:\winnt\system32")
MsgBox oFolder.Files.Count
End Sub
That should do it.
John
John Pirkey
MCSD
www.ShallowWaterSystems.com
Hmm.. that did not work
user not defined something...
im on win98 BTW..
>Add a reference to the Microsoft Scripting Runtime and paste the code in form load:
Did you do this ?
It works fine on my machine once the reference has been set.
Chris Eastwood
CodeGuru - the website for developers
http://codeguru.developer.com/vb
Here's another way to do this:
dim myFile as string
dim myDir as string
dim fileCount as string
myFile = dir(myDir,"*.*",vbFile)
do while myFile <> ""
fileCount = fileCount + 1
myFile = dir
loop
Tom Cannaerts
[email protected]
The best way to escape a problem, is to solve it.