Click to See Complete Forum and Search --> : Procedue


Sunpetch
February 28th, 2000, 01:31 AM
Can someone help me to explain this procedue?

DoEvents
TmpDir = Dir(DrivePath, vbDirectory)

Do While TmpDir <> ""

If TmpDir <> "." And TmpDir <> ".." Then

If (GetAttr(DrivePath & TmpDir) And vbDirectory) = vbDirectory Then
XDir(DirCount) = DrivePath & TmpDir & "\"
DirCount = DirCount + 1
ReDim Preserve XDir(DirCount) As String
End If
End If
TmpDir = Dir
Loop
'Searches for the files given by extensi
' on Ext
FFound = Dir(DrivePath & Ext)


Do Until FFound = ""
DrivePath
FFound = Dir
Loop
For X = 0 To (UBound(XDir) - 1)
FilesSearch XDir(X), Ext
Next X

Lothar Haensler
February 28th, 2000, 01:39 AM
to me that looks like a sub that searches all directories for files of a given extension.

the first part

TmpDir = Dir(DrivePath, vbDirectory)

Do While TmpDir <> ""

If TmpDir <> "." And TmpDir <> ".." then

If (GetAttr(DrivePath & TmpDir) And vbDirectory) = vbDirectory then
XDir(DirCount) = DrivePath & TmpDir & "\"
DirCount = DirCount + 1
ReDim Preserve XDir(DirCount) as string
End If
End If
TmpDir = Dir
Loop



stores all subdirectories within a directory in a dynamic array XDir.

The second part

FFound = Dir(DrivePath & Ext)


Do Until FFound = ""
DrivePath
FFound = Dir
Loop



searches for all files of a given extension in a single directory and calls a function DrivePath for each file found.

The third part

for X = 0 to (UBound(XDir) - 1)
FilesSearch XDir(X), Ext
next X





iterates over all subdirectories and calls a FilesSeach function for each subdirectory.