Connecting Tech Pros Worldwide Forums | Help | Site Map

List of Folders

Newbie
 
Join Date: Aug 2006
Posts: 3
#1: Aug 18 '06
Is there a way to list only the folders of a certain path in a List box? If so...how do I go about doing that.

What I want to do is list all the folders in C:\Folder1\ and Display the Names of the Folders in a List Box

Thank you in advance

BSOB's Avatar
Member
 
Join Date: Jul 2006
Location: Maine
Posts: 77
#2: Aug 18 '06

re: List of Folders


not exactly a text box, but there is a directory object.

The "Directory List Box" is a tool on the standard toolbox. 8th from the top, left side, with the image of a windows folder.

private sub form_load()
Dir1.Path = "C:\folder1\"
end sub

if you need to have it in a list box, (be ware, there are better ways then what i have here), then you can try the following code:

'(have your dir1.visible = false)
private sub form_load()
Dir1.Path = "C:\folder1\"
Dim x as integer
For x = 0 To Dir1.ListCount - 1
list1.AddItem (Dir1.List(x))
Next x
end sub

'that works.. but not the best way. im sure. also, your output will list the folder names with the path before them. you can do some string manipulation on your own to remove the path. if you want help with that, im game.
Expert
 
Join Date: Jul 2006
Location: Delhi India
Posts: 92
#3: Aug 23 '06

re: List of Folders


Hi...........
if u want to using the File and Folder to better way then u can use these Controls
1. Drive Control
2. Dir Control
3. File Control

Thanks.....
Reply