The Dir way :
VB Code:
'Just add a listbox (List1) 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 Private Sub Form_Load() ListFiles "C:\", "txt" End Sub




Reply With Quote