vb中怎样精确计时,精确到ms

来源:百度知道 编辑:UC知道 时间:2024/05/16 00:31:40
给出详细代码

返回开机以来经历的时间(以毫秒计)
Public Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long

或者返回系统当前时间(精确到毫秒)
Public Declare Sub GetSystemTime Lib "kernel32" Alias "GetSystemTime" (lpSystemTime As SYSTEMTIME)
Public 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

Dim x As Integer, y As Integer, t As Integer

Private Sub Command1_Click()
Timer1.Enabled = False
If t = 1 Then
Timer1.Enabled = True
Else
Timer1.Enabled = False
t = 0
End If
t = t + 1

End Sub

Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 1
End Sub

Private Sub Timer1_Timer()
If y <> S