Hello im just making a program for fun and to lean but im having trouble, what im trying to do is have a count down timer on a Form, i want the user to be able to set the time they want to count down from in this format hh:mm:ss (00:00:00), so far i have got a text box that counts down form 30, after I press the button, button1_click. Ive tried to make another text box and a button where the user can input the time there and press the button and it gets sent to the timer but hasn't worked. when you look at the code the time is stored in an int (int timeLeft so is it possible i could try to change that int value to what ever the user inputs.
C#:
using System;using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form3 : Form
{
int timeLeft;
public Form3()
{
InitializeComponent();
}
private void Form3_Load(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
if (timeLeft > 0)
{
// Display the new time left
// by updating the Time Left label.
timeLeft = timeLeft - 1;
timeLabel.Text = timeLeft + " seconds";
}
else
{
// If the user ran out of time, stop the timer, show
// a MessageBox, and fill in the answers.
timer1.Stop();
timeLabel.Text = "Time's up!";
MessageBox.Show("You didn't finish in time.", "Sorry!");
reset.Enabled = true;
}
}
private void button1_Click(object sender, EventArgs e) //starts the count down
{
timeLeft = 30;
timeLabel.Text = "30 seconds";
timer1.Start();
}
private void button2_Click(object sender, EventArgs e)
{
/// timeLabel.GetType();
My attempt at imputing ///// MessageBox.Show(this.inputText.Text);
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}