Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8326131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:40:08+00:00 2026-06-09T00:40:08+00:00

I know that if we want to display the pc time, we will use

  • 0

I know that if we want to display the pc time, we will use the below coding:

   System.Windows.Forms.Timer tmr = null;
    private void StartTimer()
    {
        tmr = new System.Windows.Forms.Timer();
        tmr.Interval = 1000;
        tmr.Tick += new EventHandler(tmr_Tick);
        tmr.Enabled = true;
    }

    void tmr_Tick(object sender, EventArgs e)
    {
        textBox6.Text = DateTime.Now.ToString("dd/MM/yy HH:mm:ss");
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        StartTimer();
    }

But I do not want to display the pc time. I want to display another time (the rtc time from microcontroller for my case).

If I get the rtc time from serial port and displayed into the text box as “09:00:00”. It is just static there right? How do I get it to run/increment on the text box?

I’ve tried the below which I modified from above coding:

    System.Windows.Forms.Timer rtc = null;
    private void StartRTC()
    {
        rtc = new System.Windows.Forms.Timer();
        rtc.Interval = 1000;
        rtc.Tick += new EventHandler(rtc_Tick);
        rtc.Enabled = true;
    }
    int i = 1;
    DateTime dt = new DateTime();
    void rtc_Tick(object sender, EventArgs e)
    {
        textBox17.Text = dt.AddSeconds(i).ToString("HH:mm:ss");
        i++;
    }

But the time showed on my text box always start increment on 00:00:00.

How do I let it to start increment on the time I get from my microcontroller rtc?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:40:10+00:00Added an answer on June 9, 2026 at 12:40 am

    That’s because you’re starting with new DateTime() and so you’re getting and default value of a new DateTime class. You should initialize the value of the DateTime with the API call to the microprocessor.

    Example

    Please note because I know nothing about the API for your microprocessor I can only write psuedo-code. In your second example, replace the following line…

    DateTime dt = new DateTime();
    

    with…

    DateTime dt = DateTime.Parse({some microprocessor API call for the RTC value});
    

    Edited based off of last comment

    System.Windows.Forms.Timer rtc = null; 
    DateTime dt;  // NOTE I DON'T INITIALIZE THIS TO ANYTHING AT FIRST
    
    private void StartRTC() 
    { 
        rtc = new System.Windows.Forms.Timer(); 
        rtc.Interval = 1000; 
        rtc.Tick += new EventHandler(rtc_Tick); 
    } 
    
    void rtc_Tick(object sender, EventArgs e) 
    { 
        // NOTE I GOT RID OF i - THAT WASN'T GOING TO WORK LIKE THAT 
        // YOU JUST WANT TO ADD ONE SECOND BECAUSE THE TIMER TICKS EVERY SECOND:
        textBox17.Text = dt.AddSeconds(1).ToString("HH:mm:ss");
    
        dt = DateTime.Parse(textBox17.Text);
    }
    
     // I HAVE NO IDEA WHAT YOUR METHOD HANDLER IS CALLED, THIS IS 
     // JUST FOR THE EXAMPLE
    void buttonSetRtc_Click(object sender, EventArgs e)  
    {
        // HERE IS YOUR CALL TO THE MICROCONTROLLER FOR THE INITIAL TIME:
        textBox17.Text = {some call to the microcontroller};  
        dt = DateTime.Parse(textBox17.Text);  // NOW THIS LINE WON'T FAIL
        rtc.Enabled = true;  // NOTE I MOVED THIS LINE TO KEEP IT FROM FAILING
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to know that when we want to use push notification service.From where
this is another question that I want to know that how to apply any
I know that when you want to have a value in the form like
I know that if I want to have requests for MyPage.aspx go to the
I am using MediaWiki version 1.18.2, I know that if I want my links
I just want to know that can i make an application which have some
I know that in OOP you want every object (from a class) to be
I want to know that is there any better method to do : var
I want to know that how to follow a page on Twitter using android
I want to know that how one should proceed in building animated splash screen.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.