0

I am creating an application which has 3 text boxes, the user inputs two integer values and then 3rd text box is a readonly box and is meant to contain the sum of the two input values. all these input values are then supposed to be adding to their corresponding fields int he database table. Can some one help show me the code that can implement this?

1
  • 1
    What have you tried? Where are you stuck? Also "the database" is a very vague description - there are countless ways of talking to a myriad of different types of database. But I suspect int.Parse or int.TryParse are a good starting point... Commented Jul 18, 2010 at 8:44

1 Answer 1

1

As Marc said, your question is very vague, maybe you need something like:

        int a, b, c;
        if (int.TryParse(textBox1.Text, out a) && int.TryParse(textBox2.Text, out b))
        {
            c = a + b;
            textBox3.Text = c.ToString();
            myNumberRepository.Add(c); //Assuming you already have a way to write to the DB;
        }

Assuming your accessing the UI elements directly by name. If your binding to values in the code behind or a viewmodel replace textBoxX.Text with those values.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.