VB 계산기
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
뭐 뭐 모양이 되고 있다…
Reference
이 문제에 관하여(VB 계산기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/Miya49_p0/items/e8d72b50dd43dc27a626텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)