代碼如下:
namespace 雙色球單式
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Start();
}
private void button2_Click(object sender, EventArgs e)
{
timer1.Stop();
}
private void timer1_Tick(object sender, EventArgs e)
{
Random r = new Random();
int x;
x = r.Next(1, 33);
string a = x == 1 ? "01" : x == 2 ? "02" : x == 3 ? "03" : x == 4 ? "04" : x == 5 ? "05" : x == 6 ? "06" : x == 7 ? "07" : x == 8 ? "08" : x == 9 ? "09" : x.ToString();
x = r.Next(1, 33);
string b = x == 1 ? "01" : x == 2 ? "02" : x == 3 ? "03" : x == 4 ? "04" : x == 5 ? "05" : x == 6 ? "06" : x == 7 ? "07" : x == 8 ? "08" : x == 9 ? "09" : x.ToString();
x = r.Next(1, 33);
string c = x == 1 ? "01" : x == 2 ? "02" : x == 3 ? "03" : x == 4 ? "04" : x == 5 ? "05" : x == 6 ? "06" : x == 7 ? "07" : x == 8 ? "08" : x == 9 ? "09" : x.ToString();
x = r.Next(1, 33);
string d = x == 1 ? "01" : x == 2 ? "02" : x == 3 ? "03" : x == 4 ? "04" : x == 5 ? "05" : x == 6 ? "06" : x == 7 ? "07" : x == 8 ? "08" : x == 9 ? "09" : x.ToString();
x = r.Next(1, 33);
string t = x == 1 ? "01" : x == 2 ? "02" : x == 3 ? "03" : x == 4 ? "04" : x == 5 ? "05" : x == 6 ? "06" : x == 7 ? "07" : x == 8 ? "08" : x == 9 ? "09" : x.ToString();
x = r.Next(1, 33);
string m = x == 1 ? "01" : x == 2 ? "02" : x == 3 ? "03" : x == 4 ? "04" : x == 5 ? "05" : x == 6 ? "06" : x== 7 ? "07" : x== 8 ? "08" : x == 9 ? "09" : x.ToString();
label1.Text = a;
label2.Text = b;
label3.Text = c;
label4.Text = d;
label5.Text = t;
label6.Text = m;
Random h = new Random();
int k;
k = h.Next(1, 16);
string n = k == 1 ? "01" : k == 2 ? "02" : k == 3 ? "03" : k == 4 ? "04" : k == 5 ? "05" : k == 6 ? "06" : k == 7 ? "07" : k == 8 ? "08" : k == 9 ? "09" : k.ToString();
label7.Text = n;
}
private void button3_Click(object sender, EventArgs e)
{
MessageBox.Show("提示將要推出程序");
this.Close();
}
}
}