Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble with if circulating
    primarykey
    data
    text
    <p>My problem is that my program here have trouble circulating between the functions of button21 depending on in which order the if statements is written the if does function work but the other wont. in the following code i have set it to be button2 which works however i want both the buttons 1 and two to work with button21 if theyre chosen. however the function setting qw==1 is the one working in this program not qw==2 so what is the problem with my program code? the code is displayed:</p> <pre class="lang-c# prettyprint-override"><code>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(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload