需要呼叫apiPrivate 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
If CreateDirectoryEx("c:\windows", DirPath & DirName, ByVal 0&) = 0 Then MsgBox "False Created Directory" Exit Sub End If 能不能給我解釋下,這段什麽意思呢?我是VB的初學者啊。謝謝。
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
MsgBox "False Created Directory"
Exit Sub
End If
能不能給我解釋下,這段什麽意思呢?我是VB的初學者啊。謝謝。
這句也看不懂啊?
FolderName = Year(Date) & Month(Date) & Day(Date) & Hour(Time) & Minute(Time) & Second(Time)'创建文件夹
Fso.CreateFolder ("D\" & FolderName)完成
Dim strpath As String
strpath = Now
strpath = Replace(Now, ":", ":")
MkDir "d:\" & strpath
End Sub