谢谢,又来个问题,vb6中怎么得到一个文件夹下面的所有文件夹的名称
2个回答
展开全部
'fvFolderPath表示所给文件夹
Public Sub GetSubDirs(ByRef fvFolderPath As String)
Dim oFso As New FileSystemObject
Dim oParentFolder As Folder
Dim oFolders As Folders
Dim oFolder As Folder
Dim vFolderName As String
Dim oCollection As New VBA.Collection
Set oParentFolder = oFso.GetFolder(fvFolderPath)
‘得到所给文件夹的子文件夹集合
Set oFolders = oParentFolder.SubFolders
’循环,得到每个子文件夹名称,并写入ocollection集合中
For Each oFolder In oFolders
vFolderName = oFolder.Name
Call oCollection.Add(vFolderName)
Debug.Print vFolderName
Next
End Sub
Public Sub GetSubDirs(ByRef fvFolderPath As String)
Dim oFso As New FileSystemObject
Dim oParentFolder As Folder
Dim oFolders As Folders
Dim oFolder As Folder
Dim vFolderName As String
Dim oCollection As New VBA.Collection
Set oParentFolder = oFso.GetFolder(fvFolderPath)
‘得到所给文件夹的子文件夹集合
Set oFolders = oParentFolder.SubFolders
’循环,得到每个子文件夹名称,并写入ocollection集合中
For Each oFolder In oFolders
vFolderName = oFolder.Name
Call oCollection.Add(vFolderName)
Debug.Print vFolderName
Next
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询