0

Hi to All,

I am accessing text box value and error is operator '-' cannot be applied to operands of type System.web.UI.WebControls.TextBox and int

4
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by sknake
0

Are you accessing the ToString() property of the textbox? If not, you're not working with the string value itself, you're trying to alter the TextBox control. Are you trying to subtract two numbers or are you working with text input?

0

Here is an example:

private void button6_Click(object sender, EventArgs e)
    {
      int i1;
      int i2;
      if (int.TryParse(textBox1.Text, out i1) && int.TryParse(textBox2.Text, out i2))
      {
        int sum = i1+i2;
        textBox3.Text = "The sum is " + sum.ToString();
      }
    }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.