how to set timer interval in minutes.
Any one :D
Printable View
how to set timer interval in minutes.
Any one :D
You would initially set Interval = 60000 which is 1 minute.
On Timer event you can increment integer variable and when its value is equal to whatever number you need you'll do something and reset the counter to zero.
You counter vaiable can be declare at the form level or as Static directly in the procedure (timer event handler).
Code:Option Explicit
Private lngMinutes As Long
Private intInterval As Integer
Private Sub Command1_Click()
intInterval = 2 ' Set this to the desired number of minutes
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Interval = 60000 ' set to one minute
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
lngMinutes = lngMinutes + 1
If lngMinutes = intInterval Then
lngMinutes = 0
Debug.Print "Timer fired at " & Time
' Put the code (or a call to the code) you want to execute here
End If
End Sub