dim T1 as date,T2 as date,N as long t1=now:t2=now do until abs(datediff("s",t1,t2))>=n t2=now:doevents:sleep 1 loop 这样不占资源,不影响程序的其他部分执行。
'*API函数声明: Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) '调用: '注释:延时1秒 Call Sleep(1000)
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
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'调用:
'注释:延时1秒
Call Sleep(1000)
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)调用方法:
...
Sleep(1000) '等待1000毫秒。
...嘿嘿,加点说明,盗亦有道。
Start = Timer ' 设置开始暂停的时刻。
Do While Timer < Start + PauseTime
DoEvents ' 将控制让给其他程序。
Loop
t1=now:t2=now
do until abs(datediff("s",t1,t2))>=n
t2=now:doevents:sleep 1
loop
这样不占资源,不影响程序的其他部分执行。
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'调用:
'注释:延时1秒
Call Sleep(1000)
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