I am working on Windows Application.
In a form I dragged one label and one timer control.
I have written the following code:-
On form load event:-
private void timer1_Tick(object sender, EventArgs e)
bool status = false;
label1.Text = DateTime.Now.ToLongTimeString();
DateTime time = Convert.ToDateTime("10:05:00 PM");
if (DateTime.Now.ToLongTimeString() == time.ToLongTimeString())
MessageBox.Show("Perfect Code.", "Timer Control", MessageBoxButtons.OK, MessageBoxIcon.Information);
I was running program at 10 pm so I entered 10 pm. Enter the timing after the current time.
Error in this program is that when the user time is equal to system time Message Box is shown 9 times. Help me sort out this.
Thanks in Advance....
Edited 17-Aug-12 9:06am
I set the time Interval of timer control to 1000, now it's showing only once.
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)