|
|

楼主 |
发表于 2007-8-6 19:06:00
|
显示全部楼层
Re:关于vb延时的问题
自己写了段代码,好像还是不行,大家看看。
Option Explicit
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Type TIMECAPS
min As Long
max As Long
End Type
Private Declare Function timeGetDevCaps Lib "winmm" (ByRef ptc As TIMECAPS, ByVal cbtc As Long) As Long
Private Declare Function timeBeginPeriod Lib "winmm" (ByVal uPeriod As Long) As Long
Private Declare Function timeEndPeriod Lib "winmm" (ByVal uPeriod As Long) As Long
Private Sub Command1_Click()
Dim i As Long
Dim j As Long
Dim a As TIMECAPS
Dim c%, d%, e%
c = timeGetDevCaps(a, 8)
d = timeBeginPeriod(1)
e = timeEndPeriod(1)
Me.Cls
i = GetTickCount
j = timeGetTime
Sleep 1
i = GetTickCount - i
j = timeGetTime - j
Print i
Print j
Print a.max
Print a.min
Print c
Print d
Print e
End Sub
结果:
15
15
1000000
1
0
0
0
搞笑的是,一旦浏览网页,结果变为:
0
2
1000000
1
0
0
0
真是奇妙,会不会是优先级的问题? |
|