LMCKC207
Member
- Joined
- Apr 9, 2020
- Messages
- 17
- Programming Experience
- Beginner
CODE FOR MY BUTTONS 0-9:
Private Sub btnNumbers_Click(sender As Object, e As EventArgs) Handles btn9.Click, btn8.Click, btn6.Click, btn5.Click, btn4.Click, btn3.Click, btn2.Click, btn1.Click, btn0.Click
Dim btnNum As Button = CType(sender, Button)
input = CDbl(btnNum.Text)
If txtInput.Text = "0" Or flag = True Then
txtInput.Text = ""
txtInput.Text = btnNum.Text
flag = False
Else
txtInput.Text = txtInput.Text & btnNum.Text
End If
End Sub
CODE FOR MY OPERATORS:
Private Sub btnSign(sender As Object, e As EventArgs) Handles btnMultiply.Click, btnMinus.Click, btnDivide.Click, btnAdd.Click
Dim btnSigns As Button = CType(sender, Button)
operation = btnSigns.Text
If txtInput.Text <> 0 Then
operation = btnSigns.Text
txtHistory.Text = txtHistory.Text & " " & txtInput.Text & " " & btnSigns.Text
flag = True
Else
operation = btnSigns.Text
txtHistory.Text = txtHistory.Text & " " & txtInput.Text & " " & btnSigns.Text
flag = True
End If
End Sub
My solution is like this:
- user input a number on txtInput.text then save it to variable 1.
- if the user presses an operator and input another number in txtInput.text that number will be saved to variable2 since variable1 has already a number in it.
- if the user presses an operator again do the calculation.
What I'm struggling with, is how can I keep track of the variable2? because I can track the variable1 obviously.
I don't know what event should I trigger to keep track of the variable2.