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.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sanjeeb LenkaPosted Jun 26, 2013, 12:31 AM
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
Iftikar HussainPosted Jun 26, 2013, 12:09 AM
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.