How can I get a right value in label2 that when I click on the equal button at the second or more time? Please help.. I am stuck

private void button3_Click(object sender, EventArgs e)
        {
            if (label1.Text == "0" || isActivity == true) {
                label1.Text = ""; isActivity = false;
            }
            if (label1.Text.Length < 28)
                label1.Text += "9";
            else
                SystemSounds.Beep.Play();
        }
        private void button12_Click(object sender, EventArgs e)
        {
            //label2 is a label to keep all process  -and- isActivity is a boolean to apply operators whether pressed
            //result is decimal variable to keep data to compute
            //label1 is a label to keep values when click on numbers's button
            //op is a string variable to keep operators */-+
            if (label2.Text == "") {
                label2.Text = label1.Text + "+";
                result = Convert.ToDecimal(label1.Text);
                isActivity = true;
                op = "+";
            }
            else if (label2.Text.Contains("=")) {
                label2.Text += "+";
                isActivity = true;
                op = "+";
            }
            else  {
                label2.Text += label1.Text + "+";
                result += Convert.ToDecimal(label1.Text);
                label1.Text = result.ToString();
                isActivity = true;
            }
        }

Here is also a screen capture

Attachments hesap.PNG 44.03 KB

create a public variable for your result (which is populated when you hit '=' ), clear it only when you hit Clear.. upon hitting '=' the second time, if the public var > 0, then do not reprocess the calculation

Thanks for your suggestion to make my code fix but I did like that finally.

Attachments hesap2.bmp_.png 42.96 KB
This article has been dead for over six months. Start a new discussion instead.