dim tmp as string tmp = Dir("c:\", vbDirectory) Do While tmp <> "" ' 开始循环。 If tmp <> "." And tmp <> ".." Then ' 使用位比较来确定 tmp 代表一目录。 Debug.Print tmp ' 如果它是一个目录,将其名称显示出来。 End If tmp = Dir ' 查找下一个目录。 Loop
显示文件夹: dim tmp as string tmp = Dir("c:\", vbDirectory) Do While tmp <> "" ' 开始循环。 If tmp <> "." And tmp <> ".." Then ' 使用位比较来确定 tmp 代表一目录。 If (GetAttr("c:\"& tmp) And vbDirectory) = vbDirectory Then Debug.Print tmp ' 如果它是一个目录,将其名称显示出来。 End If End If tmp = Dir ' 查找下一个目录。 Loop
Dim str As String str = Dir("c:\temp\*", vbDirectory) Do Until str = "" If GetAttr("c:\temp\" & str) = vbDirectory Then Print str str = Dir(, vbDirectory) Loop
tmp = Dir("c:\", vbDirectory)
Do While tmp <> "" ' 开始循环。
If tmp <> "." And tmp <> ".." Then
' 使用位比较来确定 tmp 代表一目录。
Debug.Print tmp ' 如果它是一个目录,将其名称显示出来。
End If
tmp = Dir ' 查找下一个目录。
Loop
dim tmp as string
tmp = Dir("c:\", vbDirectory)
Do While tmp <> "" ' 开始循环。
If tmp <> "." And tmp <> ".." Then
' 使用位比较来确定 tmp 代表一目录。
If (GetAttr("c:\"& tmp) And vbDirectory) = vbDirectory Then
Debug.Print tmp ' 如果它是一个目录,将其名称显示出来。
End If
End If
tmp = Dir ' 查找下一个目录。
Loop
我说的是在c:\temp目录下的子文件夹,不是c:\下的子文件夹!!!
str = Dir("c:\temp\*", vbDirectory)
Do Until str = ""
If GetAttr("c:\temp\" & str) = vbDirectory Then Print str
str = Dir(, vbDirectory)
Loop