利用KERNEL32 API函数实现的通用延时函数DELAY

利用KERNEL32 API函数实现的通延时函数DELAY():
使用这个函数,就能轻松的实现启动窗体时需要延时几秒钟的愿望了,而且,不会因为机器性能的不同,而造成动态效果有太大的差别,因为依靠的是时间的间隔(当然,如果还是486就不好说了),精度在0.05秒左右。

Public Declare Function GetTickCount Lib "kernel32" () As Long
Const MS_DELAY = 50 '20FPS

Public Function Delay(Times As Single)
Dim mblnRunning As Boolean
Dim mlngTimer As Long
Dim caculate As Single
mblnRunning = True
caculate = 0
Do While mblnRunning And caculate < Times
    If mlngTimer + MS_DELAY <= GetTickCount() Then
       mlngTimer = GetTickCount()
       caculate = caculate + 0.05
    End If
    DoEvents 'Important,or you can do nothing while delaying!
Loop
End Function


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值