请问如何查找C盘下所有后缀名为BMP的文件?
就是查找所有
*.bmp
问题点数:0、回复次数:3Top
1 楼captainivy(Ivy)回复于 2003-11-07 17:53:37 得分 0
新建工程
添加一个filelistbox 一个dirlistbox 一个drivelistbox 两个listbox 一个commandbutton
代码:
Private Sub Command1_Click()
List2.Clear
File1.Pattern = "*.bmp"
Dir1.Path = "c:\"
For i = 0 To Dir1.ListCount - 1
List2.AddItem Dir1.List(i)
Next
File1.Path = Dir1.Path
For j = 0 To File1.ListCount - 1
List1.AddItem Dir1.Path + File1.List(j)
Next
j = 0
On Local Error GoTo en
List2.ListIndex = j
While s < List2.ListCount
Dir1.Path = List2.List(s) + "\"
File1.Path = Dir1.Path
For j = 0 To File1.ListCount - 1
List1.AddItem Dir1.Path + "\" + File1.List(j)
Next
For t = 0 To Dir1.ListCount - 1
List2.AddItem Dir1.List(t)
Next
s = s + 1
Wend
en:
End SubTop
2 楼longki(农民写代码)回复于 2003-11-07 18:01:37 得分 0
If Running% Then: Running% = False: Exit Sub
Dim drvbitmask&, maxpwr%, pwr%
On Error Resume Next
FileSpec$ = InputBox("Enter a file spec:" & vbCrLf & vbCrLf & _
"Searching will begin at drive A and continue " & _
"until no more drives are found. " & _
"Click Stop! at any time." & vbCrLf & _
"The * and ? wildcards can be used.", _
"Find File(s)", "*.exe")
If Len(FileSpec$) = 0 Then Exit Sub
MousePointer = 11
Running% = True
UseFileSpec% = True
mnuFindFiles.Caption = "&Stop!"
mnuFolderInfo.Enabled = False
List1.Clear
drvbitmask& = GetLogicalDrives()
If drvbitmask& Then
maxpwr% = Int(Log(drvbitmask&) / Log(2)) ' a little math...
For pwr% = 0 To maxpwr%
If Running% And (2 ^ pwr% And drvbitmask&) Then _
Call SearchDirs(Chr$(vbKeyA + pwr%) & ":\")
Next
End If
Running% = False
UseFileSpec% = False
mnuFindFiles.Caption = "&Find File(s)..."
mnuFolderInfo.Enabled = True
MousePointer = 0
Picture1.Cls
Picture1.Print "Find File(s): " & List1.ListCount & " items found matching " & """" & FileSpec$ & """"
Beep
End If
End If
该需要什么控件就不用说了吧!Top
3 楼skywolfY(莫愁)回复于 2003-11-07 23:58:43 得分 0
dir 就行了Top




