|
-
June 3rd, 2010, 08:23 AM
#1
Re: Add the content of multiple textboxes
You need to convert each textbox to numeric before you add them together rather than after.
Always use [code][/code] tags when posting code.
-
June 3rd, 2010, 08:59 AM
#2
Re: Add the content of multiple textboxes
I figured it out I needed to use Int32.Parse - now it counts.
Int32 Sum = 0;
Sum = Int32.Parse(textBox6.Text) + Int32.Parse(textBox7.Text);
textBox12.Text = Sum.ToString();
-
June 3rd, 2010, 09:08 AM
#3
[RESOLVED] Add the content of multiple textboxes
I am writing a yahtzee game. I am trying to add the contents of mutliple textboxes. If textbox6 and textbox7 have 2,2 it should be 4, however it is just catnating 22. Any help would be appreciated. I am in my third week of a c# class.
private void button3_Click_1(object sender, EventArgs e)
{
int Sum = 0;
Sum = Convert.ToUInt16(textBox6.Text + textBox7.Text);
textBox12.Text = Sum.ToString();
-
June 3rd, 2010, 09:23 AM
#4
Re: Add the content of multiple textboxes
You need to convert each textbox to numeric before you add them together rather than after.
Always use [code][/code] tags when posting code.
-
June 3rd, 2010, 09:35 AM
#5
Re: Add the content of multiple textboxes
I thought I was converting before adding by using Convert.ToUInt16 before adding
int Sum = 0;
Sum = Convert.ToUInt16(textBox6.Text + textBox7.Text);
//textBox12.Text = Sum.ToString();
textBox12.Text = Convert.ToString(Sum);
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|