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 7933689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:24:25+00:00 2026-06-03T21:24:25+00:00

I’ve got 3 textboxes, (Hours, Minutes, Seconds), a start, pause and stop button and

  • 0

I’ve got 3 textboxes, (Hours, Minutes, Seconds), a start, pause and stop button and I am using labels to show the current timer. I also have a timer with an interval of 1000. My question is why won’t this display the time using the labels? Everything else works, it just won’t register that I’ve put values in the textboxes.

Code

Start Timer:

    private void startbutton_Click(object sender, EventArgs e)
    {
        if (paused != true) //Timer is not paused (active)
        {

            int.TryParse(textBoxhrs.Text, out hours);
            int.TryParse(textBoxmin.Text, out minutes);
            int.TryParse(textBoxsec.Text, out seconds);

            if (hours >= 1 || (minutes >= 1) || (seconds >= 1))

            //If there is at least one integer entered in any of the 3 boxes, executes; else - //throws an exception
            {
                startbutton.Enabled = true;
                pausebutton.Enabled = true; //changed the value to 'true'  
                stopbutton.Enabled = true; //changed the value to 'true'
                textBoxhrs.Enabled = false;
                textBoxmin.Enabled = false;
                textBoxsec.Enabled = false;
            }
            else
            {
                MessageBox.Show("Enter at least one integer!");
            }
        }
    }

    private void stopbutton_Click(object sender, EventArgs e)
    {
        // Stop the timer. 
        paused = false;
        timer1.Enabled = false;
        startbutton.Enabled = true; //changed to true
        stopbutton.Enabled = false; //changed to false
        pausebutton.Enabled = false; //changed to false
        textBoxsec.Clear();
        textBoxmin.Clear();
        textBoxhrs.Clear();
        textBoxhrs.Enabled = true;
        textBoxsec.Enabled = true;
        textBoxmin.Enabled = true;
        textBoxhrs.Enabled = true;
        lblHr1.Text = "00";
        lblMin1.Text = "00";
        lblSec1.Text = "00";
        MessageBox.Show("Timer is Stopped, to re-start press <Start>"); //updated to give user a chance to run the timer again after stoppage.

    }

Pause Button:

    private void pausebutton_Click(object sender, EventArgs e)
    {
        // Pause the timer. 
        timer1.Enabled = false;
        paused = true; //
        startbutton.Enabled = true; // changed to true
        pausebutton.Enabled = false; //changed to false
    }

Timer:

    private void timer1_Tick(object sender, EventArgs e)
    {
        // Verify if the time didn't pass.
        if ((minutes == 0) && (hours == 0) && (seconds == 0))
        {
            // If the time is over, clear all settings and fields.
            // Also, show the message, notifying that the time is over.
            timer1.Enabled = false;
            MessageBox.Show(textBoxMsg.Text);
            pausebutton.Enabled = false;
            stopbutton.Enabled = false;
            startbutton.Enabled = true;
            textBoxMsg.Clear();
            textBoxsec.Clear();
            textBoxmin.Clear();
            textBoxhrs.Enabled = true;
            textBoxMsg.Enabled = true;
            textBoxsec.Enabled = true;
            textBoxmin.Enabled = true;
            textBoxhrs.Enabled = true;
            lblHr1.Text = "00";
            lblMin1.Text = "00";
            lblSec1.Text = "00";
        }
        else
        {
            // Else continue counting.
            if (seconds < 1)
            {
                seconds = 59;
                if (minutes == 0)
                {
                    minutes = 59;
                    if (hours != 0)
                        hours -= 1;

                }
                else
                {
                    minutes -= 1;
                }
            }
            else
                seconds -= 1;
            // Display the current values of hours, minutes and seconds in
            // the corresponding fields.
            lblHr1.Text = hours.ToString();
            lblMin1.Text = minutes.ToString();
            lblSec1.Text = seconds.ToString();
        }
    }
  • 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-03T21:24:27+00:00Added an answer on June 3, 2026 at 9:24 pm

    You need to do two things to get it working:

    You need to start the timer in startbutton_Click:

    if (hours >= 1 || (minutes >= 1) || (seconds >= 1))
    
    //If there is at least one integer entered in any of the 3 boxes, executes; else - //throws an exception
    {
        startbutton.Enabled = true;
        ...
        timer1.Enabled = true;
    }
    

    You need to hook up the timer Tick event to timer1_Tick. You can do this by selecting the timer and clicking on the lightning bolt toolbar icon on the Properties frame, then selecting timer1_Tick for Tick.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Specifically, suppose I start with the string string =hello \'i am \' me And
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.