2011-04-05 96 views
0

我在powerpoint中創建了一個倒數計時器,並使用了kernel32 sleep API(在ppt中)。 在計時器運行大量時間後退出幻燈片模式(但保持宏運行狀態)時,會導致我的Windows桌面完全無法使用並變得完全無法使用(屏幕會變成奇怪的灰色)。桌面偶爾回來並重新開始工作,但是打開IE會導致屏幕再次獲取所有的screwey。VB:睡眠API問題

任何想法可能會導致這個問題?定時器代碼低於

  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 
+0

當使用'睡眠'時,'DoEvents'不應該是必需的,因爲當你的宏睡眠時'睡眠'控制其他進程。 – 2011-04-06 07:12:15

回答

0

使用DoEvents可能會導致一些相當奇怪的問題。嘗試使用計時器而不是睡眠/ DoEvents。