-
Hi everyone. I wonder if i can have some help?:
I want my program to do the following:
1) Ask the user to specify a directory
2) List all the directorys within this directory which match a certain criteria (e.g. number of files < 5) to a combo box.
Any ideas?
-
Something like:
Code:
Private Sub Command1_Click()
Dim sSubs() As String
Dim lSubs As Long
Dim sDir As String
Dim lFiles As Long
Combo1.Clear
If Right(txtDir, 1) <> "\" Then txtDir = txtDir & "\"
sDir = Dir(txtDir & "*", vbDirectory)
While Len(sDir)
If Left$(sDir, 1) <> "." Then
If (GetAttr(txtDir & sDir) And vbDirectory) = vbDirectory Then
ReDim Preserve sSubs(lSubs)
sSubs(lSubs) = sDir
lSubs = lSubs + 1
End If
End If
sDir = Dir
Wend
If lSubs = 0 Then Exit Sub
For lSubs = 0 To lSubs - 1
sDir = Dir(txtDir & sSubs(lSubs) & "\*.*", vbHidden + vbNormal + vbSystem)
lFiles = 0
While Len(sDir)
If Left(sDir, 1) <> "." Then lFiles = lFiles + 1
sDir = Dir
Wend
If lFiles < Val(txtFiles) Then Combo1.AddItem txtDir & sSubs(lSubs)
Next
End Sub
This will only list Directories immeadiately in the specified Directory, if you want it to go down further you'll have to use Recursion.
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
Thanks a lot. I haven't tried the code yet, but knowing your record, I'm sure it will work perfectly! I'll post with the results.
-
Great! It works, thank you so much. I really appreciate the help that you have given me and everybody else on this forum.
Thanks again
Mark