→ remmurds:"test"box @@? 01/10 08:30
我寫了一個程式有十個button每個button點下去後都會出現一個亂數,
然後那個亂數值會傳到一個textBox中,
目前我是做了一個textBox1,所以button的值都會跑到textBox1中,
可是我想要做兩個textBox,
讓第一個亂數值傳到textBox1中,第二個亂數值跑到textBox2中,
要怎麼解決呢??
private void button1_Click(object sender, EventArgs e)
{
Random rs = new Random();
int a = rs.Next(6); // int 0-6亂數
button1.Text = a.ToString();
textBox1.text += button1.Text;
}
private void button2_Click(object sender, EventArgs e)
{
Random rs = new Random();
int a = rs.Next(6); // int 0-6亂數
button2.Text = a.ToString();
textBox1.Text += button2.Text;
}
private void button3_Click(object sender, EventArgs e)
{
Random rs = new Random();
int a = rs.Next(6); // int 0-6亂數
button3.Text = a.ToString();
textBox1.Text += button3.Text;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.112.0.244