Hello, I was supposed to make a calculator for my assignment but when I wrote the code it didn't seem to work and the = button didn't work properly. it would be greatly appreciated if you could help...

Here is the code:



Public Class Form1

Dim FirstNumber As Single
Dim SecondNumber As Single
Dim Answer As Single
Dim Operation As String

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

TextBox1.AppendText(4)

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

TextBox1.AppendText(1)

End Sub

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

TextBox1.AppendText(2)

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

TextBox1.AppendText(3)

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

TextBox1.AppendText(5)

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

TextBox1.AppendText(6)

End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

TextBox1.AppendText(7)

End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click

TextBox1.AppendText(8)

End Sub

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click

TextBox1.AppendText(9)

End Sub

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click

TextBox1.AppendText(0)

End Sub

Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click

FirstNumber = Val(TextBox1.Text)
TextBox1.Text = "+"
Operation = "+"

End Sub

Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click

FirstNumber = Val(TextBox1.Text)
TextBox1.Text = "0"
Operation = "-"

End Sub

Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click

FirstNumber = Val(TextBox1.Text)
TextBox1.Text = "0"
Operation = "*"

End Sub

Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click

FirstNumber = Val(TextBox1.Text)
TextBox1.Text = "0"
Operation = "/"

End Sub

Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click

If Operation = "+" Then
Answer = FirstNumber + SecondNumber
End If
If Operation = "-" Then
Answer = FirstNumber - SecondNumber
End If
If Operation = "*" Then
Answer = FirstNumber * SecondNumber
End If
If Operation = "/" Then
Answer = FirstNumber / SecondNumber
End If
TextBox1.Text = Answer


End Sub

Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click

TextBox1.Clear()

End Sub

Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click

TextBox1.AppendText(".")

End Sub
End Class