|
-
February 3rd, 2000, 02:58 PM
#1
Number of files in a folder
I need some code that will count the # of files in a directory.
If u can help it would be appreciated.
Lee S
-
February 3rd, 2000, 04:04 PM
#2
Re: Number of files in a folder
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
John Pirkey
MCSD (VB6)
http://www.stlvbug.org
-
February 3rd, 2000, 05:46 PM
#3
Re: Number of files in a folder
Hmm.. that did not work
user not defined something...
im on win98 BTW..
-
February 4th, 2000, 04:43 AM
#4
Re: Number of files in a folder
>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
-
February 4th, 2000, 11:18 AM
#5
Re: Number of files in a folder
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|