7,763
社区成员
发帖
与我相关
我的任务
分享
Private Declare Function CreateDirectoryEx Lib "kernel32" Alias "CreateDirectoryExA" (ByVal lpTemplateDirectory As String, ByVal lpNewDirectory As String, lpSecurityAttributes As Any) As Long
Private Sub Command1_Click()
Dim DirPath, DirName
DirPath = App.Path
DirPath = IIf(Right(DirPath, 1) <> "\", DirPath = DirPath & "\", DirPath)
'得到月份,月份小於10自動加0
V_month = IIf(Month(Date) < 10, "0" & Month(Date), Month(Date))
'得到日期,日期小於10自動加0
V_day = IIf(Day(Date) < 10, "0" & Day(Date), Day(Date))
V_hour = Hour(Time)
'得到分鐘,分種小於10自動加0
V_min = IIf(Minute(Time) < 10, "0" & Minute(Time), Minute(Time))
'得到秒種,秒種小於10自動加0
V_sec = IIf(Second(Time) < 10, "0" & Second(Time), Second(Time))
'合併
DirName = Year(Date) & V_month & V_day & V_hour & V_min & V_sec
Debug.Print DirName
If CreateDirectoryEx("c:\windows", DirPath & DirName, ByVal 0&) = 0 Then
MsgBox "False Created Directory"
Exit Sub
End If
End Sub