Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: GUI
sir
 
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 20:28pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

SHALU DIXIT wrote:
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.
  Permalink  
Rate this: bad
good
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);
}
 
Regards,
 
Nilesh Shah.
  Permalink  
Comments
Johnny J. at 25-May-10 5:11am
   
I think you're missing a ToString() here....
Rate this: bad
good
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
            try
            {
                // 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
                textBox1.Clear();
                textBox2.Clear();
            }
        }
 
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 | [Rose]
  Permalink  
v2

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

  Print Answers RSS
0 Maciej Los 315
1 OriginalGriff 233
2 Aajmot Sk 224
3 Richard MacCutchan 220
4 Marcin Kozub 210
0 OriginalGriff 7,853
1 Sergey Alexandrovich Kryukov 7,107
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,790


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 22 May 2010
Copyright © CodeProject, 1999-2014
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