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
0
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.
Thread starter Similar threads Forum Replies Date
B Apps General Discussion 1
S Apps General Discussion 1
J Apps General Discussion 1
S Apps General Discussion 2
P Apps General Discussion 1
Fancdew15 Apps General Discussion 6
Lumia925 Apps General Discussion 8
B Apps General Discussion 4
B Apps General Discussion 6
D Apps General Discussion 8
S Apps General Discussion 1
Rafael Mestdag Apps General Discussion 5
S Apps General Discussion 4
BlueFireZ Apps General Discussion 0
S Apps General Discussion 4
W Apps General Discussion 2
U Apps General Discussion 1
UItmaWepn Apps General Discussion 0
I Apps General Discussion 3
A Apps General Discussion 2

ASK THE COMMUNITY