Running a specific task at specific time of the day
I am trying to write a program using Timer function and Timer control. I have to send a file everyday through email at 9 am. I do have the code which looks like this:
Private Sub tmrSaleCode_Timer()
'MyTime = TimeSerial(10, 19, 0)
If Start1 = 0 Then
Start1 = Timer
End If
Pause = 86400
'Pause1 = 1000
If Timer < Start1 Then
Start1 = Timer
End If
If Timer > (Start1 + Pause1) Then
'If MyTime = Time Then
Start1 = Timer
Module1.TestSndMail
Label2.Caption = "Last Update = " & Now()
'Else
' Start1 = Timer
'End If
End If
End Sub
How can I change this to make it work?
Re: Running a specific task at specific time of the day
Here is a simple routine using a Timer control that will trigger a hit when the current timeofday = > than your desired time
option Explicit
Dim myTime as date
private Sub Command2_Click()
myTime = "2:23:00PM"
print myTime
Timer1.Interval = 1000 ' one second imtervals
Timer1.Enabled = true
End Sub
private Sub Timer1_Timer()
If time >= myTime then
MsgBox "Got a hit"
Timer1.Enabled = false
End If
End Sub
John G