February 3rd, 2000, 01:58 PM
I need some code that will count the # of files in a directory.
If u can help it would be appreciated.
Lee S
If u can help it would be appreciated.
Lee S
|
Click to See Complete Forum and Search --> : Number of files in a folder February 3rd, 2000, 01:58 PM I need some code that will count the # of files in a directory. If u can help it would be appreciated. Lee S Johnny101 February 3rd, 2000, 03:04 PM 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 February 3rd, 2000, 04:46 PM Hmm.. that did not work user not defined something... im on win98 BTW.. Chris Eastwood February 4th, 2000, 03:43 AM >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 Cakkie February 4th, 2000, 10:18 AM 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 slisse@planetinternet.be The best way to escape a problem, is to solve it. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |