c# - Alarm Clock Not Updating -


i'm trying make small program using c# tells me when next metro due for. i've coded far when change system time, next metro label doesn't change. ideas what's going wrong?

namespace metroalarm  {    public partial class form1 : form    {        public form1()        {            initializecomponent();        }         public string time;        public datetime nexttime;         private void form1_load(object sender, eventargs e)        {           updatetime();           updatenext();        }         public void updatetime()        {           time = datetime.now.tostring("h:mm:ss tt");           lbltime.text = time;           lblnext.text = nexttime;        }         public void updatenext()        {           if (datetime.now <= metro1)           {              nexttime = metro1;           }            if(datetime.now >= metro1)           {              nexttime = metro2;           }            if (datetime.now >= metro2 )           {              nexttime = metro3;           }             if (datetime.now >= metro3)           {              nexttime = metro4;           }            if (datetime.now >= metro4)           {              nexttime = metro5;           }            if (datetime.now >= metro5)           {              nexttime = lastmetro;           }       }         private void updateclock_tick(object sender, eventargs e)        {           updatetime();           updatenext();        }         datetime metro1 = convert.todatetime("7:57:00 am");        datetime metro2 = convert.todatetime("8:09:00 am");        datetime metro3 = convert.todatetime("8:20:00 am");        datetime metro4 = convert.todatetime("8:33:00 am");        datetime lastmetro = convert.todatetime("8:45:00 am");    } } 

you need timer this:

timer timer1 = new timer();  public form1() {     initializecomponent();     timer1.tick += updateclock_tick;     timer1.start(); } 

also show nexttime in lblnext.text should use toshorttimestring() this:

public void updatetime() {     time = datetime.now.tostring("h:mm:ss tt");     lbltime.text = time;     lblnext.text = nexttime.toshorttimestring(); } 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -