Hi all:
I have a program that is supposed to run different procedures when an alarm goes off. Unfortunately, the alarm never goes off. I've made this work before, but for some reason, it isn't now.
[code>>frmScheduler]
Private Sub Timer1_Timer()
Static AlarmSounded As Integer
Dim Boo As Boolean
On Error Resume Next
If lblTime.Caption <> CStr(Time) Then
' It's now a different second than the one displayed.
If Second(Now) = 0 Then
Boo = GetNextScheduleTime(CStr(Time))
End If
'If Time = AlarmTime And Not AlarmSounded Then
If Boo And Not AlarmSounded Then
Beep
'Enter the run code here
MsgBox "This is where to put the code to run the email program", vbOKOnly, App.Title
'frmAdmin.StartProcess
AlarmSounded = True
ElseIf Time < AlarmTime Then
AlarmSounded = False
End If
If WindowState = conMinimized Then
' If minimized, then update the form's Caption every minute.
If Minute(CDate(Caption)) <> Minute(Time) Then SetCaptionTime
Else
' Otherwise, update the label Caption in the form every second.
lblTime.Caption = Time
End If
End If
End Sub
[/code]
[code>>Public module]
Public Function GetNextScheduleTime(ByVal strTime As String) As Boolean
Dim i As Integer
Dim Boo As Boolean
Dim itmX As ListItem
For i = 0 To frmScheduler.LV1.ListItems.Count - 1
Set itmX = frmScheduler.LV1.ListItems(i)
If Hour(CDate(itmX.SubItems(1))) = Hour(CDate(strTime)) Then
If Minute(CDate(itmX.SubItems(1))) = Minute(CDate(strTime)) Then
AlarmTime = CDate(itmX.SubItems(1))
Boo = True
Exit For
Else
Boo = False
Exit For
End If
Else
Boo = False
End If
Next
GetNextScheduleTime = Boo
End Function
[/code]
The timer works in the fact that it hits the function, but the function always returns false. In fact, it stops on the bolded line: Set itmX = frmScheduler.LV1.ListItems(i)
Any help will be greatly appreciated.
Ron Repp
If gray hair is a sign of wisdom, then I'm a genius.
My newest novel: Wooden Warriors
I have a program that is supposed to run different procedures when an alarm goes off. Unfortunately, the alarm never goes off. I've made this work before, but for some reason, it isn't now.
[code>>frmScheduler]
Private Sub Timer1_Timer()
Static AlarmSounded As Integer
Dim Boo As Boolean
On Error Resume Next
If lblTime.Caption <> CStr(Time) Then
' It's now a different second than the one displayed.
If Second(Now) = 0 Then
Boo = GetNextScheduleTime(CStr(Time))
End If
'If Time = AlarmTime And Not AlarmSounded Then
If Boo And Not AlarmSounded Then
Beep
'Enter the run code here
MsgBox "This is where to put the code to run the email program", vbOKOnly, App.Title
'frmAdmin.StartProcess
AlarmSounded = True
ElseIf Time < AlarmTime Then
AlarmSounded = False
End If
If WindowState = conMinimized Then
' If minimized, then update the form's Caption every minute.
If Minute(CDate(Caption)) <> Minute(Time) Then SetCaptionTime
Else
' Otherwise, update the label Caption in the form every second.
lblTime.Caption = Time
End If
End If
End Sub
[/code]
[code>>Public module]
Public Function GetNextScheduleTime(ByVal strTime As String) As Boolean
Dim i As Integer
Dim Boo As Boolean
Dim itmX As ListItem
For i = 0 To frmScheduler.LV1.ListItems.Count - 1
Set itmX = frmScheduler.LV1.ListItems(i)
If Hour(CDate(itmX.SubItems(1))) = Hour(CDate(strTime)) Then
If Minute(CDate(itmX.SubItems(1))) = Minute(CDate(strTime)) Then
AlarmTime = CDate(itmX.SubItems(1))
Boo = True
Exit For
Else
Boo = False
Exit For
End If
Else
Boo = False
End If
Next
GetNextScheduleTime = Boo
End Function
[/code]
The timer works in the fact that it hits the function, but the function always returns false. In fact, it stops on the bolded line: Set itmX = frmScheduler.LV1.ListItems(i)
Any help will be greatly appreciated.
Ron Repp
If gray hair is a sign of wisdom, then I'm a genius.
My newest novel: Wooden Warriors