[Solved] How do I calculate values from multiple textboxes and display in seperate box? [closed]


You can use both a RichTextBox and normal TextBox for this. To ensure that it is read-only, in the designer page do the following;

Select the TextBox > Scroll under properties window > Behavior Section > Read-Only property
Setting this property to true will make the TextBox non-editable by the user.

After you have the 4 editable TextBoxes and 1 non-editable, you can implement something like the following to add up the numeric values of TextBoxes and display it in the readonly TextBox.

    private void AverageAndDisplay()
    {
        try
        {
            //Convert values to numeric
            decimal one = Convert.ToDecimal(textBox1.Text);
            decimal two = Convert.ToDecimal(textBox2.Text);
            decimal three = Convert.ToDecimal(textBox3.Text);
            decimal four = Convert.ToDecimal(textBox4.Text);

            //Find the average
            decimal average = (one + two + three + four) / 4.0m;

            //Show the average, after formatting the number as a two decimal string representation
            textBox5.Text = string.Format("{0:0.00}", average);
        }
        catch(Exception e) //Converting to a number from a string can causes errors
        {
            System.Diagnostics.Debug.WriteLine(e.Message);
        }
    }

solved How do I calculate values from multiple textboxes and display in seperate box? [closed]