Private Declare Function timeGetTime Lib "winmm.dll" () As Long Private Declare Function timeBeginPeriod Lib "winmm.dll" (ByVal uPeriod As Long) As Long Private Declare Function timeEndPeriod Lib "winmm.dll" (ByVal uPeriod As Long) As Long
用timer返回的小数部分就是现在的毫秒是吗,我这样写Dim c Dim Now_time() As String Dim Time_int As Integer Now_time = Split(Timer, ".") Time_int = UBound(Now_time) If Time_int = 1 Then c = Now & ":" & Now_time(1) MsgBox c Else c = Now MsgBox c End If 这样得到的时间准吗?呵呵
Private Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)Private Type SYSTEMTIME 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 TypePrivate Sub Form_Load() Me.Timer1.Enabled = True Me.Timer1.Interval = 1 End SubPrivate Sub Timer1_Timer() Dim t As SYSTEMTIME, strt As String GetSystemTime t With t strt = (t.wHour + 8) Mod 24 & ":" & t.wMinute & ":" _ & t.wSecond & "." & t.wMilliseconds End With Me.Caption = strt End Sub
Timer 函数
返回一个 Single,代表从午夜开始到现在经过的秒数。语法Timer说明Microsoft Windows中,Timer函数返回一秒的小数部分
Private Declare Function timeBeginPeriod Lib "winmm.dll" (ByVal uPeriod As Long) As Long
Private Declare Function timeEndPeriod Lib "winmm.dll" (ByVal uPeriod As Long) As Long
Dim Now_time() As String
Dim Time_int As Integer
Now_time = Split(Timer, ".")
Time_int = UBound(Now_time)
If Time_int = 1 Then
c = Now & ":" & Now_time(1)
MsgBox c
Else
c = Now
MsgBox c
End If
这样得到的时间准吗?呵呵
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 TypePrivate Sub Form_Load()
Me.Timer1.Enabled = True
Me.Timer1.Interval = 1
End SubPrivate Sub Timer1_Timer()
Dim t As SYSTEMTIME, strt As String
GetSystemTime t
With t
strt = (t.wHour + 8) Mod 24 & ":" & t.wMinute & ":" _
& t.wSecond & "." & t.wMilliseconds
End With
Me.Caption = strt
End Sub