打印

【xnwxq】等待和延时函数模块

[复制链接]
1419|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
xnwxq|  楼主 | 2009-8-23 15:52 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Function Wait (numseconds As Long)
    Dim start As Variant, rightnow As Variant
    Dim HourDiff As Variant, MinuteDiff As Variant, SecondDiff As Variant
    Dim TotalMinDiff As Variant, TotalSecDiff As Variant
    start = Now

    While True
        rightnow = Now
        HourDiff = Hour(rightnow) - Hour(start)
        MinuteDiff = Minute(rightnow) - Minute(start)
        SecondDiff = Second(rightnow) - Second(start) + 1

        If SecondDiff = 60 Then
            MinuteDiff = MinuteDiff + 1 ' Add 1 To minute.
            SecondDiff = 0 ' Zero seconds.
        End If

        If MinuteDiff = 60 Then
            HourDiff = HourDiff + 1 ' Add 1 To hour.
            MinuteDiff = 0 ' Zero minutes.
        End If
        TotalMinDiff = (HourDiff * 60) + MinuteDiff' Get totals.
        TotalSecDiff = (TotalMinDiff * 60) + SecondDiff

        If TotalSecDiff >= numseconds Then
            Exit Function
        End If

        DoEvents
            'Debug.Print rightnow
        Wend
    End Function

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:我们都是风雨中的孩子,手牵着手才不会跌倒

162

主题

294

帖子

1

粉丝