好的,我已经用VBA玩了大约一个星期,只是写了一些小东西,看看我能做什么和不能做什么。我从帮助文件中得到了这个小片段,并根据需要对其进行了修改
- Public Sub GetFolderList(BlockLibrary As String)
- Dim FileName As String
- Dim FileList() As Variant
- Dim Counter As Single
- ' Display the names of the files that represent directories.
- FileName = Dir(BlockLibrary, vbDirectory) ' Retrieve the first entry.
- Counter = 0
- ReDim FileList(Counter)
- Do While FileName "" ' Start the loop.
- ' Ignore the current directory and the encompassing directory.
- If FileName "." And FileName ".." Then
- ' Use bitwise comparison to make sure FileName is a directory.
- If (GetAttr(BlockLibrary & FileName) And vbDirectory) = vbDirectory Then
- Debug.Print FileName ' Display entry only if it
- FileList(Counter) = FileName
- ReDim Preserve FileList(Counter + 1)
- Counter = (1 + Counter)
- End If ' it represents a directory.
- End If
- FileName = Dir ' Get next entry.
- Loop
- End Sub
然而,我有一个问题
它看起来正常吗
我可以在函数中使用此子函数填充列表框吗
此外,我还尝试了几种方法来获取此代码,并将扩展名传递给它,以获得该文件类型的列表
谢谢
本帖以下内容被隐藏保护;需要你回复后,才能看到! 游客,如果您要查看本帖隐藏内容请 回复 |