how to display message that time is over on label.
How to display message box in label click using function
i develop on windows form application in that i compare current time and label time.
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Iftikar HussainRank #423 · 5.9K reputationPosted Jun 25, 2013, 8:09 PM EDT
You can do this as shown below
DateTime t1 = DateTime.Now;
DateTime t2 = Convert.ToDateTime("8:00:00 AM");
int diff = TimeSpan.Compare(t1.TimeOfDay, t2.TimeOfDay);
if (diff == 1)
{
MessageBox.Show("Time is Over");
}
Regards,
Iftikar
Remember to click "Mark as Answer" on the post, if it helps you.
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Jun 25, 2013, 8:31 PM EDT
You can use the TimeOfDay property and use the Compare against it.
DateTime Curtime = DateTime.Now;
DateTime lbltime= Convert.ToDateTime(Label1.Text);
int result=TimeSpan.Compare(Curtime.TimeOfDay, lbltime.TimeOfDay)
if(result==1)
{
//show your msg
}
the result returns:
-1 if Curtime is shorter than lbltime.
0 if Curtime is equal to lbltime.
1 if Curtime is longer than lbltime