# Visual Basic - List folder names in a combo box



## nick3young (Nov 18, 2003)

Hi Everyone,
Im new to visual basic and was just wondering if it is possible to list all the folder names from a specific directory in a combo box? If so, could anyone point me in the right direction?!

Thanks a lot
Nick


----------



## Aftab (Oct 15, 2003)

Try the following code.

Private Sub Command1_click()

Dim strFolder As String

strFolder = Dir("c:\*.", vbDirectory)

Do While strFolder <> ""

If Not (strFolder = "." Or strFolder = "..") Then
Combo1.AddItem strFolder
End If
strFolder = Dir()
Loop

End Sub

Where I have specified c:\*., you will need to put in the folder you want to check, for example "c:\windows\*.". Remember the file pattern "*." (asterix followed by dot.


----------



## Anne Troy (Feb 14, 1999)

aftab, can I publish that? 
I'm doing something like this: http://vbaexpress.com/kb/e0001.htm


----------



## Aftab (Oct 15, 2003)

Please, feel free to do with it as you wish. :up:


----------

