📄 module1.bas
字号:
Attribute VB_Name = "Module1"
Public Function FindFolder(FolderName As String) As Boolean
'查找文件夹,并且在没有的情况下创建文件夹
'创建fso对象模型
' 由于fso对象包含在scripting 类型库 (scrrun.dll)中,所以在使用前首先需要在在工程中引用这个文件,单击“工程”,“引用”,然后在“引用”对话框中选中“microsoft scripting runtime”前的复选框,然后单击“确定”。
Dim fso As New FileSystemObject
Dim file As String
Dim FindHere As Boolean
'file = App.Path & "\" & FolderName
file = "c:\" & FolderName
'FolderExists 函数用来判断文件夹是否存在
FindHere = fso.FolderExists(file)
If FindHere = True Then
'找到文件夹
FindFolder = True
Else
'找到不文件夹
FindFolder = False
End If
'创建文件夹
If FindHere = False Then
fso.CreateFolder (file)
End If
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -