I have 3 text boxes 1TB,2TB and 3TB. I would like to multiply 1TB by 2TB and put the answer in 3TB. Can anyone help me with this code. Im new to C# and I keep getting errors.
Thanks in advance.

1TB,2TB and 3TB... ???

rite version...

TB1,TB2 and TB3

I just used those names on the forum the real text boxes are properly labeled.

Int32 res=Int32.Parse(textBox1.Text);
res=res*Int32.Parse(textBox2.Text);
textBox3.Text=res.ToString();

For school work that is fine. For real world, you should use Int32.TryParse because you never know what will be in those text boxes.

int result_1;
int result_2;
if (Int32.TryParse(textBox1.Text, out result_1)
     && Int32.TryParse(textBox2.Text, out result_2))
{
      textBox3.Text = (result_1 * result_2).ToString();
}
Int32 res=Int32.Parse(textBox1.Text);
res=res*Int32.Parse(textBox2.Text);
textBox3.Text=res.ToString();

What if they are decimals?

then use Double res .. Double.Parse(...) or Double.TryParse(...)

How do I only allow numeric in the text box?

How do I only allow numeric in the text box?

Did you click on the link in message #8?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.