Hello everyone
i want to get all file in a folder to a listbox using visual basic 6.0

example:
i have many files in a foldre mp3,dat,mpg etc file in D:\musicfolder
and we use a listbox and a timer or command botton
when i click on command botton then listbox additems to D:\musicfolder
please help me to solve this problem
Thanks

You need to use filelistbox for the purpose.

See if this helps :

Private Sub ListFiles(strPath As String, Optional Extention As String)
'Leave Extention blank for all files
    Dim File As String
       
    If Right$(strPath, 1) <> "\" Then strPath = strPath & "\"
       
    If Trim$(Extention) = "" Then
        Extention = "*.*"
    ElseIf Left$(Extention, 2) <> "*." Then
        Extention = "*." & Extention
    End If
       
    File = Dir$(strPath & Extention)
    Do While Len(File)
        List1.AddItem File
        File = Dir$
    Loop
End Sub

To get all files :

Private Sub Command1_Click()
ListFiles "D:\musicfolder", "*" ' Or ListFiles "D:\musicfolder", "" leave it blank to get all files
End Sub

Just get mpg files :

Private Sub Command1_Click()
ListFiles "D:\musicfolder", "mpg" 'mpg files
End Sub

Thanks Jx_Man you are a genius Thanks for help
its work

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.