Hello, I have a windows form 2 textboxes, 1, button, 1 label.
I click button and first number is divided by second.
the result is displayed in a label.
I have an exception that if someone inputs a letter an error will come back- but I also want a message to show if I try to divide by 0.
I have pasted code.
private void button1_Click(object sender, EventArgs e)
double num1 = double.Parse(textBox1.Text);
double num2 = double.Parse(textBox2.Text);
label1.Text = (num1 / num2).ToString();
catch (Exception ex)
MessageBox.Show("error:" + ex.Message);