|This is the code i am using on an if statement:|
private void button1_Click(object sender, EventArgs e)
if ((textBox1.Text==null) || (textBox2.Text==null))
MessageBox.Show("Please enter both dimentions");
twidth = double.Parse(textBox1.Text);
thight = double.Parse(textBox2.Text);
area = twidth * thight;
tpsm = 10000 / ((twidth / 10) * (twidth / 10));
area = area / 100;
textBox4.Text = Convert.ToString(tpsm);
textBox3.Text = Convert.ToString(area);
The program has two text boxes that allow the imput of two variables. I am trying to prevent the program crashing if the boxes have nothing entered in them (as it cant parse a null val).
My if/else statement is meant to only get to the else part if both of the textboxes are not null. I have clearly gone wrong somewhere because it still gets to the else part if the boxes are not filled in.