VB:睡眠API问题

时间:2011-04-05 15:54:06

标签: vba timer powerpoint

我正在powerpoint中创建倒数计时器并使用kernel32 sleep API(在ppt中)。 在计时器运行了相当长的时间后退出幻灯片模式(但保持宏运行)会导致我的Windows桌面完全失控并变得完全无法使用(屏幕变成奇怪的灰色)。桌面会逐渐恢复并再次开始工作,但是打开IE会导致屏幕再次变为全部screwey。

知道可能导致此问题的原因是什么?定时器代码

            Do While (TMinus > -1)
            'Suspend program execution for 1 second (1000 milliseconds)
            Sleep 1000

            'set hours, muinutes and seconds left based on number of seconds left (TMinus)
            cHour = Int(TMinus / 3600)
            cMin = Int((TMinus Mod 3600) / 60)
            cSec = Int((TMinus Mod 3600) Mod 60)

            'Change text in Shape 1 (timer) to reflect changed time

            .TextFrame.TextRange.Text = Format(TimeSerial(cHour, cMin, cSec), "hh:mm:ss")

            'decrement the countdown
            TMinus = TMinus - 1
            'Refreshes the display
            DoEvents
        Loop

1 个答案:

答案 0 :(得分:0)

使用DoEvents会导致一些相当奇怪的问题。尝试使用计时器而不是Sleep / DoEvents。

相关问题