public partial class Form1 : Form
{
int rndmoney1 = 100, rndmoney2 = 100, rndmoney3 = 100, rndmoney4 = 100;
int rndmoney5 = 100, rndmoney6 = 100, rndmoney7 = 100, rndmoney8 = 100;
int rndmoney9 = 100;
public Form1()
{
InitializeComponent();
button1.Enabled = false;
button2.Enabled = false;
button3.Enabled = false;
button4.Enabled = false;
button5.Enabled = false;
button6.Enabled = false;
button7.Enabled = false;
button8.Enabled = false;
button9.Enabled = false;
}
private void button8_Click(object sender, EventArgs e)
{
}
private void button10_Click(object sender, EventArgs e)
{
Random rnd = new Random();
rndmoney1 = rnd.Next(0, 9);
button1.Text = rndmoney1.ToString();
rndmoney2 = rnd.Next(0, 9);
button2.Text = rndmoney2.ToString();
rndmoney3 = rnd.Next(0, 9);
button3.Text = rndmoney3.ToString();
rndmoney4 = rnd.Next(0, 9);
button4.Text = rndmoney4.ToString();
rndmoney5 = rnd.Next(0, 9);
button5.Text = rndmoney5.ToString();
rndmoney6 = rnd.Next(0, 9);
button6.Text = rndmoney6.ToString();
rndmoney7 = rnd.Next(0, 9);
button7.Text = rndmoney7.ToString();
rndmoney8 = rnd.Next(0, 9);
button8.Text = rndmoney8.ToString();
rndmoney9 = rnd.Next(0, 9);
button9.Text = rndmoney9.ToString();
while (rndmoney2 == rndmoney1 )
{
// MessageBox.Show("錯誤");
rndmoney2 = rnd.Next(0, 9);
button2.Text = rndmoney2.ToString();
}
//rndmoney3 = rnd.Next(0, 9);
//button3.Text = rndmoney3.ToString();
while (rndmoney3 == rndmoney1 || rndmoney3 == rndmoney2)
{
// MessageBox.Show("錯誤");
rndmoney3 = rnd.Next(0, 9);
button3.Text = rndmoney3.ToString();
}
// rndmoney4 = rnd.Next(0, 9);
// button4.Text = rndmoney4.ToString();
while (rndmoney4 == rndmoney1 || rndmoney4 == rndmoney2 || rndmoney4 == rndmoney3)
{
// MessageBox.Show("錯誤");
rndmoney4 = rnd.Next(0, 9);
button4.Text = rndmoney4.ToString();
}
// rndmoney5 = rnd.Next(0, 9);
// button5.Text = rndmoney5.ToString();
while (rndmoney5 == rndmoney1 || rndmoney5 == rndmoney2 || rndmoney5 == rndmoney3 || rndmoney5 == rndmoney4)
{
// MessageBox.Show("錯誤");
rndmoney5 = rnd.Next(0, 9);
button5.Text = rndmoney5.ToString();
}
//rndmoney6 = rnd.Next(0, 9);
//button6.Text = rndmoney6.ToString();
while (rndmoney6 == rndmoney1 || rndmoney6 == rndmoney2 || rndmoney6 == rndmoney3 || rndmoney6 == rndmoney4 || rndmoney6 == rndmoney5)
{
// MessageBox.Show("錯誤");
rndmoney6 = rnd.Next(0, 9);
button6.Text = rndmoney6.ToString();
}
// rndmoney7 = rnd.Next(0, 9);
// button7.Text = rndmoney7.ToString();
while (rndmoney7 == rndmoney1 || rndmoney7 == rndmoney2 || rndmoney7 == rndmoney3 || rndmoney7 == rndmoney4 || rndmoney7 == rndmoney5 || rndmoney7 == rndmoney6)
{
// MessageBox.Show("錯誤");
rndmoney7 = rnd.Next(0, 9);
button7.Text = rndmoney7.ToString();
}
// rndmoney8 = rnd.Next(0, 9);
// button8.Text = rndmoney8.ToString();
while (rndmoney8 == rndmoney1 || rndmoney8 == rndmoney2 || rndmoney8 == rndmoney3 || rndmoney8 == rndmoney4 || rndmoney8 == rndmoney5 || rndmoney8 == rndmoney6 || rndmoney8 == rndmoney7)
{
// MessageBox.Show("錯誤");
rndmoney8 = rnd.Next(0, 9);
button8.Text = rndmoney8.ToString();
}
// rndmoney9 = rnd.Next(0, 9);
// button9.Text = rndmoney9.ToString();
while (rndmoney9 == rndmoney1 || rndmoney9 == rndmoney2 || rndmoney9 == rndmoney3 || rndmoney9 == rndmoney4 || rndmoney9 == rndmoney5 || rndmoney9 == rndmoney6 || rndmoney9 == rndmoney7 || rndmoney9 == rndmoney8)
{
// MessageBox.Show("錯誤");
rndmoney9 = rnd.Next(0, 9);
button9.Text = rndmoney9.ToString();
}
沒有留言:
張貼留言