| 发表于:2007-09-13 17:00:411楼 得分:20 |
下面的代码用计时代替定时,这样即使用 debug.print 模拟的一次操作超过 50ms,下次操作会马上触发而不用再等 50ms。 option explicit private declare function queryperformancecounter lib "kernel32 " (lpperformancecount as any) as long private declare function queryperformancefrequency lib "kernel32 " (lpfrequency as any) as long private start as currency private frequency as currency sub main() dim nextms as long dim currentms as long queryperformancefrequency frequency queryperformancecounter start nextms = 50 while nextms <= 1000 currentms = getmillisecond if currentms < nextms then doevents else debug.print "timer at " & currentms & " ms " nextms = nextms + 50 end if wend end sub function getmillisecond() as long dim current as currency queryperformancecounter current getmillisecond = ((current - start) / frequency) * 1000 end function | | |
|