I just getting started with using codebehind and I'm having a little problem. I just want to take the values from two textboxes from a form and add the values together, but I can't get it to work. Here is the error I get just trying to add the values together.<BR><BR>Operator '+' is not defined for types 'System.Web.UI.WebControls.TextBox' and 'System.Web.UI.WebControls.TextBox'.<BR><BR>Can anyone help? Thanks, Jeffyou didn't post your code, but if you don't have .value on the textbox part, it will probably break and give you the error you are getting. Maybe it is trying to add two textbox objects.
<BR><BR>try:<BR><BR>dim blah as integer = txtBox1.value + txtBox2.value<BR><BR>if that breaks... you can try this and itshould definitely work<BR><BR>dim blah as integer = CType(txtBox1.value, Integer) + CType(txtBox2.value, Integer)<BR><BR>Thanks, but it didn't work. I'm posting the code below<BR><BR>public class test<BR> inherits page<BR> public test1 as textbox<BR> public test2 as textbox<BR> public output as label<BR> public figure1 as integer = test1 + test2<BR> public sub onclick(sender as object,e as eventargs)<BR> output.text = figure1<BR> end sub<BR>end classwhere is your .aspx code? also, you don't have a test1.TEXT and test2.TEXT ... try that.In C#, you have to use the text property of the text box. Ex.<BR>string myString = txtBox1.Text;Nevermind everyone, thanks for your help. After fooling around with it I figured it all out.
