making calculator
-
You need to convert it to an int before you can add them. Use this method:
int x = Convert.ToInt32(//put string number in here); int y = Convert.ToInt32(//put string number in here); // do your calculations (x*y, x+y, etc);
Wacky waving inflateable arm flailing tube man! - Family Guyint x; int y; private void btnAdd_Click(object sender, System.EventArgs e) { int x = Convert.ToInt32.txtFirstNum; int y = Convert.ToInt32.txtSecondNum; x + y; } It doesn't recoginze the ToInt32! Is this supposed to be my answer label name?
-
int x; int y; private void btnAdd_Click(object sender, System.EventArgs e) { int x = Convert.ToInt32.txtFirstNum; int y = Convert.ToInt32.txtSecondNum; x + y; } It doesn't recoginze the ToInt32! Is this supposed to be my answer label name?
jessica gelina wrote:
int x = Convert.ToInt32.txtFirstNum; int y = Convert.ToInt32.txtSecondNum;
:omg: Can't you at least copy/paste correctly???? Regards, Nish
Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
The Ultimate Grid - The #1 MFC grid out there! -
int x; int y; private void btnAdd_Click(object sender, System.EventArgs e) { int x = Convert.ToInt32.txtFirstNum; int y = Convert.ToInt32.txtSecondNum; x + y; } It doesn't recoginze the ToInt32! Is this supposed to be my answer label name?
:confused: :confused: :confused:
-
i have two text boxes, and four buttons. Each text box allows for numbers, the buttons are teh math function. They then print the answer onclick to a seperate label. I have tries adding the strings which simply put the two numbers in the box next to one another. I have tries sending the text.tostring function to the label.......
Just need to make a few changes:
private void btnAdd_Click(object sender, System.EventArgs e) { int x = Convert.ToInt32(txtFirstNum.Text); int y = Convert.ToInt32(txtSecondNum.Text); x + y; }
That should fix it ;P Wacky waving inflateable arm flailing tube man! - Family Guy -
Just need to make a few changes:
private void btnAdd_Click(object sender, System.EventArgs e) { int x = Convert.ToInt32(txtFirstNum.Text); int y = Convert.ToInt32(txtSecondNum.Text); x + y; }
That should fix it ;P Wacky waving inflateable arm flailing tube man! - Family GuySean89 wrote:
int x; int y;
What's this bit for ? ( outside the click event handler ) Christian Graus - Microsoft MVP - C++
-
i have two text boxes, and four buttons. Each text box allows for numbers, the buttons are teh math function. They then print the answer onclick to a seperate label. I have tries adding the strings which simply put the two numbers in the box next to one another. I have tries sending the text.tostring function to the label.......
Good!!
-
Sounds just like project 5 in the Basic Programming course at St Louis Community college. Good luck. :-D
Somebody has to start somewhere. Live Life King Size Alomgir Miah
-
:confused: :confused: :confused:
He is referring to the fact that you coded:
Convert.ToInt32.txtFirstNum;
When the example clearly used brackets and specified you needed to pass in a
string
.Convert.ToInt32(txtFirstNum.Text);
ColinMackay.net Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
-
int x; int y; private void btnAdd_Click(object sender, System.EventArgs e) { int x = Convert.ToInt32.txtFirstNum; int y = Convert.ToInt32.txtSecondNum; x + y; } It doesn't recoginze the ToInt32! Is this supposed to be my answer label name?
In addition to my previous post.
jessica gelina wrote:
x + y;
Needs to assign the result to something in order for you to use it. e.g.
int result = x + y;
Then you can take the result and assign it to the
Text
property of yourLabel
. (Remember to convert it to astring
when you do that) Does this help? ColinMackay.net Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more? -
Sean89 wrote:
int x; int y;
What's this bit for ? ( outside the click event handler ) Christian Graus - Microsoft MVP - C++