請問 VB
如何用 『Filelistbox』 列出 C磁碟 底下所有的 .htm 檔
就像是搜尋 *.htm 一樣
包括 c:\\ 底下每個子機料夾中的 .htm檔喔
謝謝
2006-06-11 09:30:43 · 2 個解答 · 發問者 KAO 2 in 電腦與網際網路 ➔ 程式設計
抱歉喔~W.J.S.大大
你提供的方法只能列出 『 同層 』 目錄的檔案
不能進入 『 子資料夾 』
2006-06-12 04:49:01 · update #1
'此為VB6語法,表單置1個CommandButton跟1個FileListBoxPrivate Sub Command1_Click() File1.Pattern = "*.htm" File1.Path = "C:\" File1.Refresh Dim I% For I = 0 To File1.ListCount - 1 Print File1.List(I) NextEnd Sub
2006-06-12 18:41:40 補充:
抱歉!因為你沒說連子資料夾也必須找.所以沒寫XD.底下是我之前回答過類似的題目.你可參考看看(表單不必佈置任何元件.直接貼上去就可以)http://tw.knowledge.yahoo.com/question/?qid=1306022519965
2006-06-11 11:51:21 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋
DirListBox, FileListBox, ListBox 各一個,其結果存在 c:\filelist.txt 檔案內:Private Sub Dir1_Change() File1.Path = Dir1.Path For n = 0 To File1.ListCount - 1 If Right(File1.Path, 1) = "\" Then Open "c:\filelist.txt" For Append As #1 If LCase(Right(File1.List(n), 4)) = ".htm" Then Print #1, File1.Path + File1.List(n) End If Close #1 Else Open "c:\filelist.txt" For Append As #1 If LCase(Right(File1.List(n), 4)) = ".htm" Then Print #1, File1.Path + "\" + File1.List(n) End If Close #1 End If DoEvents NextEnd SubPrivate Sub Form_Activate() On Error Resume Next Open "c:\pathlist.txt" For Output As #1 Close #1 Open "c:\filelist.txt" For Output As #1 Close #1 For pathindex = 67 To 67 'C = 67, D = 68 ... Dir1.Path = Chr(pathindex) + ":\" i = 0 For n = 0 To Dir1.ListCount - 1 List1.AddItem Dir1.List(n) Next While i < List1.ListCount Dir1.Path = List1.List(i) For n = 0 To Dir1.ListCount - 1 Caption = Dir1.List(n) List1.AddItem Dir1.List(n) Next i = i + 1 Wend Open "c:\pathlist.txt" For Append As #1 For n = 0 To List1.ListCount - 1 Print #1, List1.List(n) Next Close #1 List1.Clear NextEnd Sub
2006-06-12 09:17:13 · answer #2 · answered by 世賢 7 · 0⤊ 0⤋