Poceo sam da ucim VB.Net malo, ide solidno, imam jedan problemcic pa ako neko moze da pomogne
Pravim kalkulator prvi i evo koda. Sve ide OK, kad odradim debugging i pokrene se program, npr. kad saberem 3 i 5 pojavi se 8 normalno. Onda odem na Clear button i obrise. Posle kad opet ocu da saberem neka dva broja opet, ono mi pamti onu trojku prvu i dodaje ovome. U cemu je problem evo koda. Inace kalkulator je krajnje jednostavan, 0-9, +, = i Clear dugme
Public Class Form1
Dim total1 As Integer
Dim total2 As Integer
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub btnZero_Click(sender As System.Object, e As System.EventArgs) Handles btnZero.Click
txtDisplay.Text = txtDisplay.Text & btnZero.Text
End Sub
Private Sub btnOne_Click(sender As System.Object, e As System.EventArgs) Handles btnOne.Click
txtDisplay.Text = txtDisplay.Text & btnOne.Text
End Sub
Private Sub btnTwo_Click(sender As System.Object, e As System.EventArgs) Handles btnTwo.Click
txtDisplay.Text = txtDisplay.Text & btnTwo.Text
End Sub
Private Sub btnThree_Click(sender As System.Object, e As System.EventArgs) Handles btnThree.Click
txtDisplay.Text = txtDisplay.Text & btnThree.Text
End Sub
Private Sub btnFour_Click(sender As System.Object, e As System.EventArgs) Handles btnFour.Click
txtDisplay.Text = txtDisplay.Text & btnFour.Text
End Sub
Private Sub btnFive_Click(sender As System.Object, e As System.EventArgs) Handles btnFive.Click
txtDisplay.Text = txtDisplay.Text & btnFive.Text
End Sub
Private Sub btnSix_Click(sender As System.Object, e As System.EventArgs) Handles btnSix.Click
txtDisplay.Text = txtDisplay.Text & btnSix.Text
End Sub
Private Sub btnSeven_Click(sender As System.Object, e As System.EventArgs) Handles btnSeven.Click
txtDisplay.Text = txtDisplay.Text & btnSeven.Text
End Sub
Private Sub btnEight_Click(sender As System.Object, e As System.EventArgs) Handles btnEight.Click
txtDisplay.Text = txtDisplay.Text & btnEight.Text
End Sub
Private Sub btnNine_Click(sender As System.Object, e As System.EventArgs) Handles btnNine.Click
txtDisplay.Text = txtDisplay.Text & btnNine.Text
End Sub
Private Sub cmdClear_Click(sender As System.Object, e As System.EventArgs) Handles cmdClear.Click
txtDisplay.Clear()
End Sub
Private Sub cmdPlus_Click(sender As System.Object, e As System.EventArgs) Handles cmdPlus.Click
total1 = total1 + Val(txtDisplay.Text)
txtDisplay.Clear()
End Sub
Private Sub cmdEquals_Click(sender As System.Object, e As System.EventArgs) Handles cmdEquals.Click
Dim total2 As Integer
total2 = total1 + Val(txtDisplay.Text)
txtDisplay.Text = total2
MsgBox(total2)
End Sub
End Class
|