int lnum1 = 0;
bool num1ingresadoOK = true;
try
{
lnum1 = int.Parse(num1.Text);
num1ingresadoOK = false;
}
catch (Exception)
{
MessageBox.Show("ERROR El primer valor NO es un numero");
}
int lnum2 = 0;
bool num2ingresadoOK = true;
try
{
lnum2 = int.Parse(num2.Text);
num2ingresadoOK = false;
}
catch (Exception)
{
MessageBox.Show("ERROR El segundo valor NO es un numero");
}
if ((num1ingresadoOK == true) && (num2ingresadoOK == true)) ;
{
if (operacion.Text == "+")
{
int total = lnum1 + lnum2;
resultado.Text = total.ToString();
}
if (operacion.Text == "-")
{
int total = lnum1 - lnum2;
resultado.Text = total.ToString();
}
else if (operacion.Text == "*")
{
int total = lnum1 * lnum2;
resultado.Text = total.ToString();
}
else if (operacion.Text == "/")
{
if (lnum2 == 0)
{
MessageBox.Show("ERROR La division por 0 NO esta establecida");
}
else
{
int total = lnum1 / lnum2;
resultado.Text = total.ToString();
}
}
resultado.Visible = true;
nuevocalculo.Visible = true;
}
}
private void Form1_Load(object sender, EventArgs e)
{
nuevocalculo.Visible = false;
resultado.Visible = false;
}
private void nuevocalculo_Click(object sender, EventArgs e)
{
num1.Text = "0";
num2.Text = "0";
resultado.Visible = false;
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (operacion.Text == "+")
{
}
}
}
}