- JarekFeatured Creator
- Posts : 335
Join date : 2018-12-06
Location : Poland
PowerPoint VBA Timer
Thu Apr 14, 2022 6:21 am
I need a time delay of less than 1 second in my new game. Can anybody share the code for a PowerPoint VBA timer that counts time in milliseconds or other units of less than 1 second? A common PowerPoint timer has 1 second intervals and the millisecond timers for Excel don't work with PowerPoint. I seem to be stuck.
Re: PowerPoint VBA Timer
Fri Apr 15, 2022 7:57 pm
- Code:
Sub Timer()
Dim time as Date
Dim sec as Single
time = Now()
sec = .5
time = DateAdd("s", sec, time)
Do Until time < Now()
DoEvents
Loop
End Sub
This is my work-around, and seems to work fine.
- JarekFeatured Creator
- Posts : 335
Join date : 2018-12-06
Location : Poland
Re: PowerPoint VBA Timer
Sat Apr 16, 2022 12:14 pm
I already tried that.
Any value less than 1 for sec gives the same result. Objects do move a bit faster (but not equivalent to sec value) and always at the same speed irrelevant of sec value. So sec=0.9 gives the same result as sec=0.5 or sec=0. Additionally, after a cycle of 10 Timer runs (on my laptop) the movement freezes for a moment and then suddenly advances 2-3 moves to make up for the delay. In other words it remains unplayable. The video shows the results with sec=0.9 and 0.1 - no speed change + freezing after 10 moves.
- Code:
time = DateAdd("s", sec, time)
Any value less than 1 for sec gives the same result. Objects do move a bit faster (but not equivalent to sec value) and always at the same speed irrelevant of sec value. So sec=0.9 gives the same result as sec=0.5 or sec=0. Additionally, after a cycle of 10 Timer runs (on my laptop) the movement freezes for a moment and then suddenly advances 2-3 moves to make up for the delay. In other words it remains unplayable. The video shows the results with sec=0.9 and 0.1 - no speed change + freezing after 10 moves.
Re: PowerPoint VBA Timer
Sat Apr 16, 2022 2:07 pm
Another trick I've used, is animating a hidden shape with a repeating animation at a very fast rate. This will help force the slide's refresh rate and you should notice a difference between .9 seconds and .5 seconds.
That may help improve performance, but isn't guaranteed to fix it.
Good Luck!
That may help improve performance, but isn't guaranteed to fix it.
Good Luck!
Permissions in this forum:
You cannot reply to topics in this forum
|
|