Private Const CB_SETCURSEL = &H14E
Private Type uSystemTime
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
'Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal CX As Long, ByVal CY As Long, ByVal wFlags As Long) As Long
Private Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As uSystemTime)
'
'名称 Fun_GetLocalTime
'作者 MornWoo20071016
'功能 获取系统的时间,精确到毫秒。
'参数 无
'返回 返回字符串数据: iFormat = 0,"YYYY-MM-DD HH:MM:SS"+" " + "毫秒数";iFormat=1,yyyymmddhhmmss毫秒数
' iFormat = 2,"YYYY-MM-DD HH:MM:SS"
'
Function Fun_GetLocalTime(Optional ByVal iFormat = 0) As String
Dim uSysTime As uSystemTime
Dim sA
GetSystemTime uSysTime
If CInt(uSysTimewHour + 8) < 24 Then
Select Case iFormat
Case 0
sA = Format(CStr(uSysTimewYear) & "-" & CStr(uSysTimewMonth) & "-" & CStr(uSysTimewDay), "yyyy-mm-dd") & _
" " & Format(CStr(uSysTimewHour + 8), "00") & ":" & Format(CStr(uSysTimewMinute), "00") & ":" & _
Format(CStr(uSysTimewSecond), "00") & "" & CStr(uSysTimewMilliseconds)
Case 1
sA = Format(CStr(uSysTimewYear) & "-" & CStr(uSysTimewMonth) & "-" & CStr(uSysTimewDay), "yyyymmdd") & _
Format(CStr(uSysTimewHour + 8), "00") & Format(CStr(uSysTimewMinute), "00") & _
Format(CStr(uSysTimewSecond), "00") & CStr(uSysTimewMilliseconds)
Case 2
sA = Format(CStr(uSysTimewYear) & "-" & CStr(uSysTimewMonth) & "-" & CStr(uSysTimewDay), "yyyy-mm-dd") & _
" " & Format(CStr(uSysTimewHour + 8), "00") & ":" & Format(CStr(uSysTimewMinute), "00") & ":" & _
Format(CStr(uSysTimewSecond), "00")
End Select
Else
Select Case iFormat
Case 0
sA = Format(CStr(uSysTimewYear) & "-" & CStr(uSysTimewMonth) & "-" & CStr(uSysTimewDay), "yyyy-mm-dd") & _
" " & Format(CStr(uSysTimewMinute), "00") & _
":" & Format(CStr(uSysTimewSecond), "00") & "" & CStr(uSysTimewMilliseconds)
Case 1
sA = Format(CStr(uSysTimewYear) & "-" & CStr(uSysTimewMonth) & "-" & CStr(uSysTimewDay), "yyyymmdd") & _
Format(CStr(uSysTimewMinute), "00") & _
Format(CStr(uSysTimewSecond), "00") & CStr(uSysTimewMilliseconds)
Case 2
sA = Format(CStr(uSysTimewYear) & "-" & CStr(uSysTimewMonth) & "-" & CStr(uSysTimewDay), "yyyy-mm-dd") & _
" " & Format(CStr(uSysTimewMinute), "00") & _
":" & Format(CStr(uSysTimewSecond), "00")
End Select
End If
Fun_GetLocalTime = sA
End FunctionPrivate Sub Timer1_Timer()
yea = Year(Date)
mon = Month(Date)
da = Day(Date)
Text1Text=yea & "年"
Text2Text=mon & "月"
Text3Text= da & "日"
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)