我檔案夾下有4000多個.htm檔案. 它給我列舉到999個就為止了. 1000后面的全丟下不管了.
我目的是用來讀取這些htm檔案正則取里面的字符.
有什么方法讓它一次性全部遍歷列舉完嗎? 謝謝!
strfile = Dir(App.Path & "\*.htm")
Do Until strfile = ""
Open strfile For Input As #7
While Not EOF(7) 'EOF為文尾測驗函式
Line Input #7, s '讀入并放在臨時字串中
Wend
Close #7
....
strfile = Dir
Loop
MsgBox "完畢"
uj5u.com熱心網友回復:
把打開讀取檔案的代碼注掉試試,以判斷是哪里出了問題。strfile = Dir(App.Path & "\*.htm")
Do Until strfile = ""
'Open strfile For Input As #7
'While Not EOF(7) 'EOF為文尾測驗函式
' Line Input #7, s '讀入并放在臨時字串中
'Wend
'Close #7
'....
Debug.Print strfile
strfile = Dir
Loop
MsgBox "完畢"
uj5u.com熱心網友回復:
沒有判斷"."與"..",可能會出問題.試試我這個封裝好的模塊看看:
http://www.m5home.com/bbs/thread-2218-1-1.html
呼叫很簡單,添加模塊后:
'搜索檔案模塊測驗程序
'BY 嗷嗷叫的老馬
'紫水晶作業室
'http://www.m5home.com/
Dim I() As String, J As Long<
I = SearchFileInPath("c:\windows\web", "*.*")
For J = 0 To UBound(I)
Debug.Print I(J) '列印所有檔案
Next
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/101131.html
標籤:網絡編程
