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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Very basic ListBox Question 1

Status
Not open for further replies.

mookie0001

Technical User
Jun 14, 2002
23
US
I know there is probably a very simple solution to this, but I am relatively inexperienced in VB so bear with me...

I am looking to list all of the folders (not any files) at a given location in a list box. I do not want to use any type of built-in directory controls because I wish to restrict the output to only the folders of a given path with no browsing ability. What would be the best way of implementing this? Thanks.
 
cannot say if this is the 'best' way ...

Code:
Dim sBase As String
Dim oFSO As Object
Dim oBase As Object
Dim oSub As Object

sBase = "C:\windows"

Set oFSO = CreateObject("scripting.filesystemobject")
Set oBase = oFSO.getfolder(sBase)
For Each oSub In oBase.subfolders
  List1.AddItem oSub.Name
Next oSub
Set oBase = Nothing
Set oFSO = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top