我的問題是,我的程序在這裏有按鈕21的功能之間循環的麻煩取決於if語句的寫法,如果功能工作,但其他不會。 在下面的代碼中,我已經將它設置爲button2,它的工作原理但是我希望按鈕1和2都使用button21,如果他們選擇的話。然而函數設置qw == 1是在這個程序中工作的不是qw == 2 那麼我的程序代碼有什麼問題? 代碼顯示:麻煩,如果循環
namespace Matematisk_indlæring
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Random RND = new Random(Guid.NewGuid().GetHashCode());
Random RND2 = new Random(Guid.NewGuid().GetHashCode());
private void quitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
button1.Hide();
button2.Hide();
button3.Hide();
button4.Hide();
button5.Hide();
label1.Show();
textBox1.Show();
button21.Show();
double qw = 1;
textBox2.Text = qw.ToString();
string q = "1+1";
label1.Text = q;
int qq = 1 + 1;
textBox3.Text = qq.ToString();
}
private void button21_Click(object sender, EventArgs e)
{
double qqq = Convert.ToDouble(textBox1.Text);
double qq = Convert.ToDouble(textBox3.Text);
int qw = Convert.ToInt32(textBox2.Text);
if (qw == 1)
{
if (qq == qqq)
{
MessageBox.Show("succes");
int qws1;
int qws;
qws1 = RND2.Next(51, 100);
qws = RND.Next(0, 50);
qq = qws1 + qws;
textBox3.Text = qq.ToString();
string tese = qws.ToString();
string tese2 = qws1.ToString();
label1.Text = tese2 + "+" + tese;
}
if (qw == 2)
{
if (qq == qqq)
{
MessageBox.Show("succes");
int qws1;
int qws;
qws1 = RND2.Next(51, 100);
qws = RND.Next(0, 50);
qq = qws1 - qws;
textBox3.Text = qq.ToString();
string tese = qws.ToString();
string tese2 = qws1.ToString();
label1.Text = tese2 + "-" + tese;
}
}
}
}
private void button2_Click(object sender, EventArgs e)
{
button1.Hide();
button2.Hide();
button3.Hide();
button4.Hide();
button5.Hide();
label1.Show();
textBox1.Show();
button21.Show();
double qw = 2;
textBox2.Text = qw.ToString();
string q = "1-1";
label1.Text = q;
int qq = 1 - 1;
textBox3.Text = qq.ToString();
}
}
}
歡迎Stackoverlfow,請閱讀[常見問題]和[提問]幾次.. – 2013-03-07 07:31:32
酷:有人把C#的Unicode支持使用。 – nneonneo 2013-03-07 07:31:46
@nneonneo:不酷:SO的語法突出顯示扼流圈:-( – 2013-03-07 07:33:25