View Single Post
 
Old 10-26-2014, 06:41 AM
megatronixs megatronixs is offline Windows 7 32bit Office 2003
Advanced Beginner
 
Join Date: Aug 2012
Posts: 42
megatronixs is on a distinguished road
Default show folders and files in listbox

Hi all,

I have a listbox that with the push of a button shows me all the files in the folder. The path is hard coded. I would like to avoid hard code all the folders so when I push a button, it shows the files from that folder.
Is there a way the code could be adjusted so it would show the folders and files in one listbox like below:

Folder1
file1
file2
Folder2
file1
file2.

This is the code I have now:

Code:
Private Sub Command23_Click()
    Dim LoadFiles   As String
    Dim strFill     As String
    
    LoadFiles = Dir$("C:\Messages\*.*")
    Do While LoadFiles > ""
       strFill = strFill & LoadFiles & ";"
       LoadFiles = Dir$
    Loop
    List21.RowSource = strFill
End Sub
greetings.
Reply With Quote