作者smallsafe (PMD給我打O吧!!)
看板Visual_Basic
標題[VB6 ] 模糊搜尋檔案
時間Thu Jun 7 16:47:44 2012
我想寫個輸入關鍵字,然後搜尋該資料夾內的檔案
目前我的做法是先搜尋該資料夾內所有檔案,
然後輸入關鍵字去分類,在由listbox列出
p = Dir("C:\windows\system32\*.*")
Do While p <> ""
List1.AddItem p
p = Dir
loop
For i = 0 To List1.ListCount - 1
If InStr(List1.List(i), Text1) Then
List2.AddItem List1.List(i)
End If
Next
不過現在我遇到的問題是我所需連線到的網路磁碟機裡面的資料太龐大了(幾萬筆)
請問有辦法在一開始搜尋的時候就只找我要的關鍵字的檔案嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 112.105.196.251
1F:→ MOONRAKER:把if instr() ... 放到do loop裡面不就結了 06/07 17:01
感謝提醒
把程式改成以下方式,果然能只列出關鍵字檔案
Dim p As String
p = Dir("C:\windows\system32\*.*")
Do While p <> ""
If InStr(p, Text1) Then
List2.AddItem p
End If
p = Dir
Loop
※ 編輯: smallsafe 來自: 112.105.196.251 (06/07 19:20)
2F:→ MOONRAKER:對嘛,這不是很簡單清楚 | ) 06/07 21:35
3F:→ smallsafe:真是感謝了... 06/08 22:24