Calculator Code
Public Class Form1
Dim firstnum As Decimal
Dim Secondnum As Decimal
Dim Operations As Integer
Dim operator_selector As Boolean = False
Private Sub Button1_Click(sender As [Link], e As [Link]) Handles
[Link]
If [Link] <> "0" Then
[Link] += "1"
Else
[Link] = "1"
End If
End Sub
Private Sub Button2_Click(sender As [Link], e As [Link]) Handles
[Link]
If [Link] <> "0" Then
[Link] += "2"
Else
[Link] = "2"
End If
End Sub
Private Sub Button3_Click(sender As [Link], e As [Link]) Handles
[Link]
If [Link] <> "0" Then
[Link] += "3"
Else
[Link] = "3"
End If
End Sub
Private Sub Button8_Click(sender As [Link], e As [Link]) Handles
[Link]
If [Link] <> "0" Then
[Link] += "4"
Else
[Link] = "4"
End If
End Sub
Private Sub Button7_Click(sender As [Link], e As [Link]) Handles
[Link]
If [Link] <> "0" Then
[Link] += "5"
Else
[Link] = "5"
End If
End Sub
Private Sub Button6_Click(sender As [Link], e As [Link]) Handles
[Link]
If [Link] <> "0" Then
[Link] += "6"
Else
Calculator Code
[Link] = "6"
End If
End Sub
Private Sub Button12_Click(sender As [Link], e As [Link]) Handles
[Link]
If [Link] <> "0" Then
[Link] += "7"
Else
[Link] = "7"
End If
End Sub
Private Sub Button11_Click(sender As [Link], e As [Link]) Handles
[Link]
If [Link] <> "0" Then
[Link] += "8"
Else
[Link] = "8"
End If
End Sub
Private Sub Button10_Click(sender As [Link], e As [Link]) Handles
[Link]
If [Link] <> "0" Then
[Link] += "9"
Else
[Link] = "9"
End If
End Sub
Private Sub Button16_Click(sender As [Link], e As [Link]) Handles
[Link]
If [Link] <> "0" Then
[Link] += "0"
End If
End Sub
Private Sub Button15_Click(sender As [Link], e As [Link]) Handles
[Link]
If Not ([Link](".")) Then
[Link] += "."
End If
End Sub
Private Sub Button4_Click(sender As [Link], e As [Link]) Handles
[Link]
firstnum = [Link]
[Link] = "0"
operator_selector = True
Operations = 1 '=+
End Sub
Private Sub Button14_Click(sender As [Link], e As [Link]) Handles
[Link]
[Link] = "0"
End Sub
Calculator Code
Private Sub Button5_Click(sender As [Link], e As [Link]) Handles
[Link]
firstnum = [Link]
[Link] = "0"
operator_selector = True
Operations = 2 '=-
End Sub
Private Sub Button9_Click(sender As [Link], e As [Link]) Handles
[Link]
firstnum = [Link]
[Link] = "0"
operator_selector = True
Operations = 3 '=*
End Sub
Private Sub Button13_Click(sender As [Link], e As [Link]) Handles
[Link]
firstnum = [Link]
[Link] = "0"
operator_selector = True
Operations = 4 '=/
End Sub
Private Sub Button17_Click(sender As [Link], e As [Link]) Handles
[Link]
If operator_selector = True Then
End If
Secondnum = [Link]
If Operations = 1 Then
[Link] = firstnum + Secondnum
ElseIf Operations = 2 Then
[Link] = firstnum - Secondnum
ElseIf Operations = 3 Then
[Link] = firstnum * Secondnum
Else
If Secondnum = 0 Then
[Link] = "error"
Else
[Link] = firstnum / Secondnum
End If
operator_selector = False
End If
End Sub
End Class