'查找特定路径下某种类型文件,将名称保存在数组中,Ubound(数组)的值即为文件个数 Sub aaa() Dim strFileName() As String Dim FileName As String Dim j As Long j = -1 FileName = Dir(你的路径 & "*.*") Do While FileName <> "" If FileName <> "." And FileName <> ".." Then j = j + 1 ReDim Preserve strFileName(j + 1) strFileName(j) = FileName End If FileName = Dir ' 查找下一个文件。 Loop End Sub
Sub aaa()
Dim strFileName() As String
Dim FileName As String
Dim j As Long
j = -1
FileName = Dir(你的路径 & "*.*")
Do While FileName <> ""
If FileName <> "." And FileName <> ".." Then
j = j + 1
ReDim Preserve strFileName(j + 1)
strFileName(j) = FileName
End If
FileName = Dir ' 查找下一个文件。
Loop
End Sub
呵呵,多注意一下VB标准控件啊。