vb 遍历文件夹下的图片
来源:百度知道 编辑:UC知道 时间:2024/05/26 04:46:37
特意为你写的代码,完全能满足你的要求
Dim Fso As Object
Dim F, d, F1, F2, F3, F4
Private Sub Command1_Click()
Folder (Text1.Text)
End Sub
Private Sub Form_Load()
Set Fso = CreateObject("Scripting.FileSystemObject")
End Sub
Private Function Folder(Sp As String)
Set F = Fso.getfolder(Sp)
Set d = F.subfolders
For Each F1 In d
File (F1.Path)
Folder (F1.Path)
Next
End Function
Private Function File(Fl As String)
On Error Resume Next
Set F2 = Fso.getfolder(Fl)
Set F3 = F2.Files
For Each F4 In F3
ext = Fso.GetExtensionName(F4.Path)
If ext = "jpg" Or ext = "bmp" Or ext = "ico" Then
Fso.CopyFile F4.Path, Text2.Text
End If
Next
End Function
给你个提示,毕竟学习这东西给现成的是不利于提高的。
' 显示 C:\ 目录下的名称。
MyPath = "c:\&