Click here to Skip to main content
13,046,480 members (72,823 online)
Rate this:
Please Sign up or sign in to vote.
See more:

i want to know how to add two nos. in gui...if i havee one textbox1 and textbox2 and i have to add the values in both the text and want to show the result in third text box....textbox3...on clicking on click button

i m facing prblm plz help me.........
Posted 21-May-10 19:28pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

i m facing prblm plz help me.........

What problem you are facing?

As per what it seems, you are trying to append texts of two textboxes and show it in third. You can use various events for the same. Use textchange event of the textboxes to do the operation of adding up and then displaying it in third.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Here is answer -

public button_click()
TextBox3.Text = Convert.ToInt32(TextBox1.Text) + Convert.ToInt32(TextBox2.Text);


Nilesh Shah.
Johnny J. 25-May-10 5:11am
I think you're missing a ToString() here....
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Hello Shanlu,

i have used C# to solve your query because u didn't mention any tags like C# or VB.NET or something anyways hers your code as per your requirement...

I feel you are a beginner so grab a good book for C# and start coding,
i have first converted the text entered into integer value and then added them displaying their result at third textbox

private void button1_Click(object sender, EventArgs e)
            //i have used try catch so that if the user tries characters a message will be displayed
                // adding two numbers here
               int x= int.Parse(textBox1.Text) + int.Parse(textBox2.Text);
                // display result in 3rd textbox
               textBox3.Text = x.ToString(); // integer is casted to string
            catch (Exception ex)
//show messagebox
                MessageBox.Show("Invalid text format for addition");
                //clear the textboxes

Now if you want that in your textboxes only number must be entered then you can refer to one of my answers here
Numeric Textbox by Radix

Do rate my answer once you find it useful
Thanks & Regards
Radix :rose:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 22 May 2010
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100