How do you store the contents of a folder in a list box?
I.E.>If I wanted to store all files located in the My Documnets folder in a list box.
Printable View
How do you store the contents of a folder in a list box?
I.E.>If I wanted to store all files located in the My Documnets folder in a list box.
Just use a FileListBox, the one next to the yellow DirListBox
Code:File1.Path = "c:\My Documents"
'This will show all files in C:\My Documents!
I am doing this off the top of my head but this should work. What Jop gave you was for a file box but if you want it in a list box what you do is this.
Add 1 file box make visible false and add 1 listbox.
That works I went and I tested it. If you only want to add certain files like only Mp3's or something make the file box only show mp3s then the list box will only add mp3s.Code:Option Explicit
Private Sub Form_Load()
Dim a As Integer
File1.Path = "c:\My Documents"
Do Until File1.ListIndex + 1 = File1.ListCount
File1.ListIndex = a
List1.AddItem File1.FileName, a
a = a + 1
Loop
End Sub
Hope this helps!!
[Edited by PITBULLCJR on 09-29-2000 at 06:05 PM]
Thanks guys!