可以使用:Private Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
sleep也行, 用DO While吧,計算時間差.
dim loopTime as long dim oldTime as date looptime=10 '延时10秒 oldtime=now while dateadd("s",looptime,oldtime)<now doevents wend
请土豆说明一下你的程序。我有点看不懂,while那部分的循环条件 。
dateadd("s",looptime,oldtime)<now 这个条件不对吧。
一:sleep 二: Function Delay(ByVal n As Single) Dim tm1, tm2 As Single tm1 = Timer Do tm2 = Timer If tm2 < tm1 Then tm2 = tm2 + 86400 If tm2 - tm1 > n Then Exit Do DoEvents Loop
在里面设置要执行的内容
就会隔一段时间,执行
同意,只要将这个函数引用进来就可以了。
用DO While吧,計算時間差.
dim oldTime as date
looptime=10 '延时10秒
oldtime=now
while dateadd("s",looptime,oldtime)<now
doevents
wend
这个条件不对吧。
二:
Function Delay(ByVal n As Single)
Dim tm1, tm2 As Single
tm1 = Timer
Do
tm2 = Timer
If tm2 < tm1 Then tm2 = tm2 + 86400
If tm2 - tm1 > n Then Exit Do
DoEvents
Loop
End Function