Reputation: 13
So I am working on a 3 digit calculator and for some reason, I can only get it to add and I don't know why. I feel like it will get pointed out to me and I will feel really stupid.
private void CalcCalcBtn_Click(object sender, EventArgs e)
{
double num1 = double.Parse(calc1Txt.Text);
double num2 = double.Parse(calc2Txt.Text);
double num3 = double.Parse(calc3Txt.Text);
{
if(calcAddBtn.Enabled == true)
{
double output = (num1 + num2 + num3);
calcOpLbl.Text = output.ToString("0.00");
}
else if(calcSubBtn.Enabled == true)
{
double output = (num1 - num2 - num3);
calcOpLbl.Text = output.ToString("0.00");
}
else if(calcMutBtn.Enabled == true)
{
double output = (num1 * num2 * num3);
calcOpLbl.Text = output.ToString("0.00");
}
else if(calcDivBtn.Enabled == true)
{
double output = (num1 / num2 / num3);
calcOpLbl.Text = output.ToString("0.00");
}
}
}
Upvotes: 1
Views: 46
Reputation: 48612
Enabled
means "is it possible for the user to click this button", not "is this the button that the user just clicked". Since all four of those buttons are always enabled, it's always true for the first, and the else
s mean that it doesn't bother looking at the rest.
Upvotes: 3