C# How to do a math operation with one button and one text box?

Status
Not open for further replies.

austinedwards7

Honorable
Aug 3, 2012
4
0
10,510
This is for school.

I want to be able to able to type a number into a text box click a button, then type another number into the same text box click a button and apply a math operation to those two numbers(In visual studio 2010 C#). Now, I don't have any trouble with the math operations, but I have no idea how to prepare for it. We have only been taught to do the operations when there were multiple boxes, by storing the values into a variable converting it, adding the two integers then converting back. I thought maybe using arrays? But we have only been taught if then statements,while loops, and bools.




This is what I have. We need to show the number of values that were put in, which is why I have number++;





public partial class frmtemp : Form
{

int number=0;






public frmtemp()
{
InitializeComponent();
}

private void frmtemp_Load(object sender, EventArgs e)
{

}

private void txt1_TextChanged(object sender, EventArgs e)
{




}

private void frmtemp_FormClosing(object sender, FormClosingEventArgs e)
{


MessageBox.Show("Numbers Added: "+number.ToString());

this.DialogResult = DialogResult.OK;




}

private void btntemp_Click(object sender, EventArgs e)
{

number++;
 
Status
Not open for further replies.