how do i make it so that when the user enters a number in the textbox, clicks an addition button, puts the second operand in the same textbox, then display the result in the textbox when the add button is clicked again?
here is my code for the add button:

private void add_Click(object sender, RoutedEventArgs e)
        {
            if (z == (int)MODE.rec)
            {
                real1 = Convert.ToDouble(x.Text);
                this.x.Focus();
                real2 = Convert.ToDouble(x.Text);
                sum1 = real1 + real2;
                sum2 = imag1 + imag2;
                s = sum1.ToString("0.000000");
                t = sum2.ToString("0.000000");
                x.Text = "" + s;
                y.Text = "" + t;
            }
        }

how do i make it so that when the user enters a number in the textbox, clicks an addition button, puts the second operand in the same textbox, then display the result in the textbox when the add button is clicked again?
here is my code for the add button:

private void add_Click(object sender, RoutedEventArgs e)
        {
            if (z == (int)MODE.rec)
            {
                real1 = Convert.ToDouble(x.Text);
                this.x.Focus();
                real2 = Convert.ToDouble(x.Text);
                sum1 = real1 + real2;
                sum2 = imag1 + imag2;
                s = sum1.ToString("0.000000");
                t = sum2.ToString("0.000000");
                x.Text = "" + s;
                y.Text = "" + t;
            }
        }

you just call the final value in textbox.like:
this.textbox1.text="name of your final value";

Hey chargeFan

Ive knocked together a quick simple example for you. Although it can be enhanced greatly.

public partial class Form1 : Form
    {
        private double opperand_A = 0;
        private bool opperand_A_Set = false;

        public Form1()
        {
            InitializeComponent();
        }

        private void btAdd_Click(object sender, EventArgs e)
        {
            if (!opperand_A_Set)
            {
                opperand_A = Convert.ToDouble(txtBox.Text);
                txtBox.Clear();
                opperand_A_Set = true;
            }
            else
            {
                txtBox.Text = (opperand_A + Convert.ToDouble(txtBox.Text)).ToString();
            }
        }
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.