Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADDING TextBox1 and TextBox2 results wrong

Status
Not open for further replies.

jsundin3

Technical User
Oct 2, 2001
60
US
Having trouble with this one, not used to VB.NET yet. Results = 0 when hitting command button.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim TextBox1 As Integer

Dim TextBox2 As Integer

Dim intTotal As Integer


intTotal = (TextBox1 + Text2)

MsgBox(intTotal)
End Sub
End Class

===ANY HELP WOULD BE APPRECIATED!!===


JeffS
 
try this enstead ...

Dim textBox1Entry as integer = val(TextBox1.Text)
Dim textBox2Entry as integer = val(TextBox2.Text)
Dim intTotal As Integer = textBox1Entry + textBox2Entry

MsgBox(intTotal)

2 things ... There is no default property in VB.net, and the TEXT is now always streated as a string.

Becca
 
thanks becca for the tip, i will give it a try. Is there a good resource that will list the differences, the book i have is ok, but no real good examples .......

Thanks Again

JeffS
 
There is no reference I know where all the changes are. I am guessing because so many things have changed. However I do have 3 very good books I use, not to mentio this web site :). "Microsoft Visual Basic.Net Step By Step" by Michael Halvorson, "Visual Basic.Net Bible" by Bill Evjen and Jason Beres, and "An Introduction To Programming Using Visual Basic.Net Fifth Edition" by David I Schneider. There are probably more good books out there, if anyone else knows of some, please list them.

Becca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top