2008-11-15 91 views

回答

15
sFilename = Dir(sFoldername) 

Do While sFilename > "" 

    debug.print sFilename 
    sFilename = Dir() 

Loop 
+0

該死的,打我吧:P 有MSDN文章可供參考: http://msdn.microsoft.com/en-us/library/aa262726(VS.60).aspx – 2008-11-15 00:42:27

4

DJ的solution是簡單而有效的,只是拋出一個又一個的情況下,你需要一點點更多的功能是FileSystemObject對象可以提供(需要Microsoft腳本運行的引用)。

Dim fso As New FileSystemObject 
Dim fil As File 

For Each fil In fso.GetFolder("C:\").Files 
    Debug.Print fil.Name 
Next 
9
Dim fso As New FileSystemObject 
Dim fld As Folder 
Dim fil As File 
Set fld = fso.GetFolder("C:\My Folder") 
For Each fil In fld.Files 
    Debug.Print fil.Name 
Next 
Set fil = Nothing 
Set fld = Nothing 
Set fso = Nothing 
0

創建名稱= browseButton 創建名稱FileListBox中鍵=列表1

設計

和代碼按鈕

雙擊應該是這樣的

Private Sub browseButton_Click() 

Dim path As String 
path = "C:\My Folder" 

List1.path() = path 
List1.Pattern = "*.txt" 
End Sub 

現在完成運行它

相關問題