Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP - DirListBox -is there a way to filter what directories are shown

Status
Not open for further replies.

robbaggio

Programmer
Jun 11, 2002
31
US
Say I have a DirListBox SubDir1 that lists the directories in the path given in a TextBox txtPath1. The thing is I only want to have SubDir list some of the directories in that path, i.e. i want to filter the directories. Is there any way to do this? (like something kind of similar to the FIleListBox's Pattern variable). If not what would be the best way to go about doing this. Thanks for all of the help in advance!

robbaggio
 
' Display the names in C:\ that represent directories.
MyPath = "c:\" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
Do While MyName <> &quot;&quot; ' Start the loop.
' Ignore the current directory and the encompassing directory.
If MyName <> &quot;.&quot; And MyName <> &quot;..&quot; Then
' Use bitwise comparison to make sure MyName is a directory.
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
Debug.Print MyName ' Display entry only if it is a directory
End If
End If
MyName = Dir ' Get next entry.
Loop



Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top