コードの簡略化は諦め、とりあえず形だけ(小数点無し)の電卓を作成。
1から自分で作成したのでツッコミどころは満載かもしれませんが、、、
Public Class Form1
Dim anser As Integer
'null=0, +=1, -=2, *=3, /=4 # =前に何の演算子であったか。
Dim before As Integer
Private Sub Form_initialize()
anser = 0
before = 0
End Sub
Private Sub btnZero_Click(sender As Object, e As EventArgs) Handles btnZero.Click
If lblAnser.Text = "0" Then
lblAnser.Text = "0"
Else
lblAnser.Text = lblAnser.Text & "0"
End If
End Sub
Private Sub btnOne_Click(sender As Object, e As EventArgs) Handles btnOne.Click
If lblAnser.Text = "0" Then
lblAnser.Text = "1"
Else
lblAnser.Text = lblAnser.Text & "1"
End If
End Sub
Private Sub btnTwo_Click(sender As Object, e As EventArgs) Handles btnTwo.Click
If lblAnser.Text = "0" Then
lblAnser.Text = "2"
Else
lblAnser.Text = lblAnser.Text & "2"
End If
End Sub
Private Sub btnThree_Click(sender As Object, e As EventArgs) Handles btnThree.Click
If lblAnser.Text = "0" Then
lblAnser.Text = "3"
Else
lblAnser.Text = lblAnser.Text & "3"
End If
End Sub
Private Sub btnFour_Click(sender As Object, e As EventArgs) Handles btnFour.Click
If lblAnser.Text = "0" Then
lblAnser.Text = "4"
Else
lblAnser.Text = lblAnser.Text & "4"
End If
End Sub
Private Sub btnFive_Click(sender As Object, e As EventArgs) Handles btnFive.Click
If lblAnser.Text = "0" Then
lblAnser.Text = "5"
Else
lblAnser.Text = lblAnser.Text & "5"
End If
End Sub
Private Sub btnSix_Click(sender As Object, e As EventArgs) Handles btnSix.Click
If lblAnser.Text = "0" Then
lblAnser.Text = "6"
Else
lblAnser.Text = lblAnser.Text & "6"
End If
End Sub
Private Sub btnSeven_Click(sender As Object, e As EventArgs) Handles btnSeven.Click
If lblAnser.Text = "0" Then
lblAnser.Text = "7"
Else
lblAnser.Text = lblAnser.Text & "7"
End If
End Sub
Private Sub btnEight_Click(sender As Object, e As EventArgs) Handles btnEight.Click
If lblAnser.Text = "0" Then
lblAnser.Text = "8"
Else
lblAnser.Text = lblAnser.Text & "8"
End If
End Sub
Private Sub btnNine_Click(sender As Object, e As EventArgs) Handles btnNine.Click
If lblAnser.Text = "0" Then
lblAnser.Text = "9"
Else
lblAnser.Text = lblAnser.Text & "9"
End If
End Sub
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
Dim num As Integer = Integer.Parse(lblAnser.Text)
If anser = 0 Then
anser = lblAnser.Text
lblAnser.Text = 0
Else
anser = anser + lblAnser.Text
lblAnser.Text = 0
End If
before = 1
End Sub
Private Sub btnDif_Click(sender As Object, e As EventArgs) Handles btnDif.Click
Dim num As Integer = Integer.Parse(lblAnser.Text)
If anser = 0 Then
anser = lblAnser.Text
lblAnser.Text = 0
Else
anser = anser - lblAnser.Text
lblAnser.Text = 0
End If
before = 2
End Sub
Private Sub btnPro_Click(sender As Object, e As EventArgs) Handles btnPro.Click
Dim num As Integer = Integer.Parse(lblAnser.Text)
If anser = 0 Then
anser = lblAnser.Text
lblAnser.Text = 0
Else
anser = anser * lblAnser.Text
lblAnser.Text = 0
End If
before = 3
End Sub
Private Sub btnQuo_Click(sender As Object, e As EventArgs) Handles btnQuo.Click
Dim num As Integer = Integer.Parse(lblAnser.Text)
If anser = 0 Then
anser = lblAnser.Text
lblAnser.Text = 0
Else
anser = anser / lblAnser.Text
lblAnser.Text = 0
End If
before = 4
End Sub
Private Sub btnResult_Click(sender As Object, e As EventArgs) Handles btnResult.Click
If before = 1 Then
anser = anser + lblAnser.Text
ElseIf before = 2 Then
anser = anser - lblAnser.Text
ElseIf before = 3 Then
anser = anser * lblAnser.Text
ElseIf before = 4 Then
anser = anser / lblAnser.Text
End If
lblAnser.Text = 0
MessageBox.Show(anser)
anser = 0
End Sub
End Class




まぁまぁ形にはなってる…はず!