Module1.bas
上传用户:szlwled
上传日期:2022-06-30
资源大小:95k
文件大小:1k
- Attribute VB_Name = "Module1"
- Public strFileAVI As String '何存视频的文件名
- Public strFileBMP As String '保存图片的文件名
- Public sngTime As Single '设置录制时长
- Public Function CreateFolder(ByVal strPath As String) As Boolean '逐层创建子文件夹
- Dim iSearch As Integer
- Dim str1 As String
- Dim FileSystemObj As Object
- On Error Resume Next
- Set FileSystemObj = CreateObject("Scripting.FileSystemObject") '创建文件对象模型
- If Not FileSystemObj.DriveExists(FileSystemObj.GetDriveName(strPath)) Then '若存在该路径
- CreateFolder = False '设置返回参数
- Exit Function '退出函数
- End If
- If Right(strPath, 1) <> "" Then '查找最后是否为“”
- strPath = strPath & "" '在最后添加“”
- End If
- iSearch = InStr(strPath, "") '搜索分隔符
- Do While iSearch <> 0
- str1 = str1 & Left(strPath, iSearch) '获取一层子文件夹名称
- strPath = Mid(strPath, iSearch + 1) '去掉前面部分字符
- MkDir str1 '创建一层子文件夹
- If (Not FileSystemObj.DriveExists(str1)) And (Not FileSystemObj.FolderExists(str1)) Then '若不存在指定驱动器,且不存在指定文件夹
- CreateFolder = False '设置返回参数
- Exit Function '退出函数
- End If
- iSearch = InStr(strPath, "") '搜索下一下分隔符“”
- Loop
- CreateFolder = True '设置返回参数
- End Function