小時鐘
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace count
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void timer_Tick(object sender, EventArgs e)
{
DateTime now = DateTime.Now;
time.Text = now.Hour + ":" + now.Minute + ":" + now.Second ;
}
}
}
倒數器
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace count
{
public partial class Form1 : Form
{
int c;
public Form1()
{
InitializeComponent();
}
private void button_Click(object sender, EventArgs e)
{
c = int.Parse(textBox1.Text);
timer.Enabled = true ;
}
private void timer_Tick(object sender, EventArgs e)
{
if (c == 0)
{
timer.Enabled = false;
time.Text = c.ToString();
MessageBox.Show("時間到 !");
}
if (c >= 0)
{
time.Text = c.ToString();
c—;
}
}
}
}





