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

Display folders only in a combo box?

Status
Not open for further replies.

BriCorbin

Technical User
Jan 28, 2004
3
NZ

Great forum! Sorry if I post some really dumb questions over the next few days, I am a complete newbie to progamming.
I want to set only the folder names inside a folder on my hard disk to display in a combo box. Done in such a way that if new folders are added or renamed the combo box will refresh.

I found a post from Golom which had this (below) which was real close but I cant figure how to show folder names only. Kudos go to Golom for such a simple piece of code that even I can understand it, just cant change it ;-)

Dim FileName As String
FileName = Dir("C:\MyDirectory\*.*")
Combo1.Clear
Do Until Len(FileName) = 0
Combo1.AddItem FileName
FileName = Dir()
Loop

 
OH I should mention that I would probably need the resultant combobox sorted alphabetically. It seems weird to a newbie that it takes so much custom work to do something as simple a list folders in a combobox!

Hope I'm not asking to much at once here.
 

Welcome to TT BriCorbin, to get the most from this site please read FAQ222-2244.

In the code window type in dir and press F1. When help pops up look at the example for Dir. You will see where they do the bitwise comparison to make sure that it is not a directory (not the &quot;..&quot; &quot;.&quot; comparison). Change the <> to = and you will have your test for directories only.

Good Luck

 

BriCorbin, have you read FAQ222-2244 yet?

Did you have any luck with the Dir function?

Good Luck

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top