Add a timer - as follows:
Dim WithEvents Timer1 As Timer
Set up your variables (or read them anywhere).
Dim runtimestring As String = "12:00 PM"
Dim nextruntime As Date
At startup, set the interval for the following runtime and start the timer:
Sub New()
'set up time interval
If Now.TimeOfDay > Date.Parse(runtimestring).TimeOfDay Then
'set nextruntime to tomorrow
nextruntime = Date.Parse(runtimestring).AddDays(1)
Else
'set nextruntime to today
nextruntime = Date.Parse(runtimestring)
End If
Timer1.Interval = nextruntime.Subtract(Now).TotalMilliseconds
Timer1.Start()
End Sub
Tick , /, , .
Sub Timer1_Tick() Handles Timer1.Tick
Timer1.Stop()
'Add your functions and sub here.....
'set nextruntime to tomorrow
nextruntime = Date.Parse(runtimestring).AddDays(1)
Timer1.Interval = nextruntime.Subtract(Now).TotalMilliseconds
Timer1.Start()
End Sub