Stopping a countup timer

M

Madhup Thakur

Hello,
WIN 98 / Office 2K/ P4 1400
I have count up timer in a Slide presentation that I wish to stop
automatically after 180 Secs. But it does not. .BTW I had used the routine
from this news group Will somebody please help me out. Thank you
M. Thakur

Option Explicit

'API Declarations

Declare Function SetTimer Lib "user32" _
(ByVal hwnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long

Declare Function KillTimer Lib "user32" _
(ByVal hwnd As Long, _
ByVal nIDEvent As Long) As Long



' Public Variables

Public SecondCtr As Integer
Public TimerID As Long
Public bTimerState As Boolean

Sub TimerOnOffRFire()

If bTimerState = False Then
TimerID = SetTimer(0, 0, 1000, AddressOf TimerProc1)
SecondCtr = 0
If TimerID = 0 Then
MsgBox "Unable to create the timer", vbCritical + vbOKOnly, "Error"
Exit Sub
End If
bTimerState = True
Else
TimerID = KillTimer(0, TimerID)
If TimerID = 0 Then
MsgBox "Unable to stop the timer", vbCritical + vbOKOnly, "Error"
End If
ActivePresentation.SlideMaster.Shapes(9).TextFrame.TextRange.Text =
CStr(SecondCtr) '"Time UP"
bTimerState = False
End If
End Sub



' The defined routine gets called every nnnn milliseconds.

Sub TimerProc1(ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal idEvent As Long, _
ByVal dwTime As Long)

SecondCtr = SecondCtr + 1
ActivePresentation.SlideMaster.Shapes(9).TextFrame.TextRange.Text =
CStr(SecondCtr)
End Sub

Sub TimerOnOff()

If bTimerState = False Then
TimerID = SetTimer(0, 0, 1000, AddressOf TimerProc)
SecondCtr = 0
If TimerID = 0 Then
MsgBox "Unable to create the timer", vbCritical + vbOKOnly, "Error"
Exit Sub
End If
bTimerState = True
Else
TimerID = KillTimer(0, TimerID)
If TimerID = 0 Then
MsgBox "Unable to stop the timer", vbCritical + vbOKOnly, "Error"
End If
ActivePresentation.SlideMaster.Shapes(9).TextFrame.TextRange.Text =
"Time UP"
bTimerState = False
End If
End Sub



' The defined routine gets called every nnnn milliseconds.

Sub TimerProc(ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal idEvent As Long, _
ByVal dwTime As Long)

SecondCtr = SecondCtr + 1
If SecondCtr < 181 Then
ActivePresentation.SlideMaster.Shapes(9).TextFrame.TextRange.Text =
CStr(SecondCtr)
Else
SecondCtr = 0
ActivePresentation.SlideMaster.Shapes(9).TextFrame.TextRange.Text =
"Time UP"
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top