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 Type Private Sub Form_Load() Dim myTime As SYSTEMTIMEGetSystemTime myTimeMe.AutoRedraw = TrueWith myTime Print "当前时间:" & .wYear & "年" & .wMonth & "月" & .wDay & "日" & " " & _ .wHour & "时" & .wMinute & "分" & .wSecond & "." & .wMilliseconds & "秒" End With End Sub
timeGettimePrivate Declare Function timeGetTime Lib "winmm.dll" () As Long
GetTickCountPublic Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long不过很耗资源的,不要在循环内使用.
访问timer值不行吗?
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 Sub Form_Load()
Dim myTime As SYSTEMTIMEGetSystemTime myTimeMe.AutoRedraw = TrueWith myTime
Print "当前时间:" & .wYear & "年" & .wMonth & "月" & .wDay & "日" & " " & _
.wHour & "时" & .wMinute & "分" & .wSecond & "." & .wMilliseconds & "秒"
End With
End Sub