vb中的sleep参数的困惑
本帖最后由 bcrun 于 2014-01-10 11:55:40 编辑 为什么使用sleep()将线程暂停后,用timeGetTime计算出前后使用的时间,然后是在不同的电脑运行,一样的参数,而时间长度会不一样呢?
代码如下:
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Function datadd1()
Dim NumBuf As Long
Dim num1 As Long
Dim num2 As Long
Dim TimeBuf As Long
num1 = Val(frmTest.Text1(0).Text)
num2 = Val(frmTest.Text2(0).Text)
Do
TimeBuf = timeGetTime
NumBuf = NumBuf + 1
If NumBuf > num1 Then
NumBuf = 0
End If
frmTest.Label1(0).Caption = NumBuf
Sleep num2
frmTest.Label2(0).Caption = timeGetTime - TimeBuf
Loop
End Function