VB:睡眠 API 问题
我正在 powerpoint 中创建一个倒计时器并利用 kernel32 sleep API(在 ppt 中)。 当计时器运行相当长的时间后退出幻灯片模式(但保持宏运行)时,会导致我的 Windows 桌面完全混乱并变得完全无法使用(屏幕变成奇怪的灰色)。桌面偶尔会回来并重新开始工作,但是打开 IE 会导致屏幕再次变得混乱。
知道什么可能导致这个问题吗?定时器代码如下
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
I'm creating a countdown timer in powerpoint and utilizing the kernel32 sleep API (in ppt).
When exiting slideshow mode (but keeping the the macro running) after the timer has been running for a substantial amount of time causes my windows desktop to completely haywire and become completely unusable (screen goes a weird grey colour). The desktop occaisionally comes back and starts working again, however opening IE causes the screen to get all screwey again.
Any idea what might be causing this problem? Timer code below
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 DoEvents 可能会导致一些相当奇怪的问题。尝试使用计时器而不是 Sleep/DoEvents。
Using DoEvents can cause some rather strange problems. Try using a timer instead of Sleep/DoEvents.