May
3
2003

Alarm Class

Replace the Timer Control with this Alarm Class

This is a very simple Alarm Class. You set the alarm to go off in so many milliseconds and it will fire the Alarm event when the inverval is reached. The API callback function TimerProc is used, hence the need for the Alarm Module.

The code is undocumented, but should be easy enough to follow.

Usage

Add AlarmClass.cls and AlarmModule.bas to your project

Option Explicit

Dim WithEvents Alarm As AlarmClass

Private Sub Alarm_Alarm()

   MsgBox "Alarm!"

End Sub

Private Sub cmdSetAlarm_Click()

   Alarm.SetAlarm 5000

End Sub

Private Sub cmdCancelAlarm_Click()

   Alarm.CancelAlarm

End Sub

Private Sub Form_Load()

   Set Alarm = New AlarmClass

End Sub

Private Sub Form_Unload(Cancel As Integer)

   Set Alarm = Nothing

End Sub

Downloads

AlarmClass.zip - contains: AlarmClass.cls, AlarmModule.bas (0.9 kb)

More...