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

[复制链接]
 楼主| 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

粉丝
快速回复 在线客服 返回列表 返回顶部
个人签名:我们都是风雨中的孩子,手牵着手才不会跌倒

162

主题

294

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部