i wan set a timer in my program to execute a certain function daily,weekly or monthly(which will decide by the user)!User also can execute manually the certain function at anytime!

any1 can teach me how 2 do these 2 function in my program?

thanks............

Hopefully you may want not a windows program running, waiting for a timer during one month.

The best way is to isolate this functionalty in a separate console application and use the task scheduler of Windows to planify when, and under wich user, must be executed.

Be aware that this console application can not have any interactive screen or message, as is running in batch, and should end gently.

Hope this helps

.

i wan design a program that have a timer to execute certain code(like send sms) at certain period.
The period is select by user(daily,monthly,weekly) and user oso can execute this certain code manually at anytime when user wan.
who can provide the code that how to set this timer?

Thanks

Dim WithEvents MyTimer as System.Timers.Timer ' to define the timer at module or class level
'
' inside de sub where you define when to fire the timer
'
Dim NumberOfSecondsToFiretheTimer As Double = 86400D ' One Day
MyTimer.Interval = NumberOfSecondsToFiretheTimer
MyTimer.Start

To catch the event

Private Sub MyTimer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles MyTimer.Elapsed
'
'  do whatever you need
' 
End Sub

i think, if your program running everyday, you can use timer event tick,then set interval, then the event you need just insert in that tick

if i wan the code execute at every monday(8am),how i nid to do?
thanks....

Use the windows task scheduler
http://support.microsoft.com/kb/308569/en-us for XP
http://windows.microsoft.com/en-US/windows-vista/Schedule-a-task for Vista
http://support.microsoft.com/kb/814596/en-us for Windows 2003
Also maybe you are interested on http://msdn.microsoft.com/en-us/library/aa383614(v=vs.85).aspx for the task scheduler API and http://msdn.microsoft.com/en-us/library/aa384006(v=vs.85).aspx showing examples about task scheduler API usage.

Hope this helps

may i got some code sample for this function?
it is bcoz i wan write the code in the program that i design so can generate a report every monday(8am).
Thanks.....
it's urgent...

You could use a timer control that constantly checks the time and when the time matches 8:00 it will run your code. An example in vb.net is below. iIuse something similar to run a SQL Backup Utility I created.

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim time As Date = Date.Now
        Dim currhour As Integer
        Dim currminute As Integer
        Dim ReportHour As Integer
        Dim ReportMinute As Integer
        currhour = time.Hour
        currminute = time.Minute
        ReportHour = 08
        ReportMinute = 00
        If currhour = ReportHour AndAlso currminute = ReportMinute Then
            RunReport()
        End If
    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.