need a bit of help please

stuart1512

New member
Joined
Oct 9, 2009
Messages
1
Programming Experience
Beginner
back ground- ive only been learning VB.net for about a week and am using a tutorial Free Beginners Computer Tutorials and Lessons.

i am at the tutorial about the calculator and have hit a snag- my problem is that i have to do the equals button but dont know how to

heres the sub of code

Private Sub btnEquals_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnEquals.Click

Total2 = Total1 + (txtDisplay.Text)
txtDisplay.Text = Total2
txtDisplay.Clear()
End Sub

i am also having trouble with the add button- here is the code for that

Private Sub btnPlus_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles btnPlus.Click

Total1 = Total1 + Val(txtDisplay.Text)
txtDisplay.Clear()
End Sub


any help would be greatly appreciated thanks in advance


stuart
 
VB.NET:
Private Sub btnEquals_Click(...) Handles btnEquals.Click


[COLOR="SeaGreen"]    '01) What datatype is Total1 & Total2 and where are they declared?
    '02) In your first line, you are adding a number datatype(?) together with text. You should explicitly contvert the textbox value to a numeric datatype first.
    '03) You are then assigning the numeric datatype back into a text property. Again you would need to convert the numeric variable to a string to assign to the textbox.[/COLOR]

    Total2 = Total1 + (txtDisplay.Text)
    txtDisplay.Text = Total2
    txtDisplay.Clear()

End Sub
 
Back
Top