Option ExplicitPrivate Declare Sub GetLocalTime 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 SYSTEMTIME 'Set the graphical mode to persistent Me.AutoRedraw = True 'Get the local time GetLocalTime MyTime 'Print it to the form Me.Print "The Local Date is:" & MyTime.wMonth & "-" & MyTime.wDay & "-" & MyTime.wYear Me.Print "The Local Time is:" & MyTime.wHour & ":" & MyTime.wMinute & ":" & MyTime.wSecond End Sub
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 SYSTEMTIME
'Set the graphical mode to persistent
Me.AutoRedraw = True
'Get the local time
GetLocalTime MyTime
'Print it to the form
Me.Print "The Local Date is:" & MyTime.wMonth & "-" & MyTime.wDay & "-" & MyTime.wYear
Me.Print "The Local Time is:" & MyTime.wHour & ":" & MyTime.wMinute & ":" & MyTime.wSecond
End Sub
vc用long型表示的时间和systemtime不通用