天天看點

vb簡易計算機的代碼,vb的簡易電腦代碼

該樓層疑似違規已被系統折疊 隐藏此樓檢視此樓

Dim OperatorState As Integer

Dim data1 As Integer

Dim data2 As Integer

Dim result As Integer

Private Sub Command1_Click()

Text1.Text = "7"

End Sub

Private Sub Command10_Click()

Text1.Text = "6"

End Sub

Private Sub Command11_Click()

Text1.Text = "3"

End Sub

Private Sub Command12_Click()

Text1.Text = ""

End Sub

Private Sub Command13_Click()

data1 = Val(Text1.Text)

OperatorState = 1

Text1.Text = Text1.Text + ""

End Sub

Private Sub Command14_Click()

data1 = Val(Text1.Text)

OperatorState = 2

Text1.Text = Text1.Text + ""

End Sub

Private Sub Command15_Click()

data1 = Val(Text1.Text)

OperatorState = 3

Text1.Text = Text1.Text + ""

End Sub

Private Sub Command16_Click()

data1 = Val(Text1.Text)

OperatorState = 4

Text1.Text = Text1.Text + ""

End Sub

Private Sub Command2_Click()

Text1.Text = "4"

End Sub

Private Sub Command3_Click()

Text1.Text = "1"

End Sub

Private Sub Command4_Click()

Text1.Text = "0"

End Sub

Private Sub Command5_Click()

Text1.Text = "8"

End Sub

Private Sub Command6_Click()

Text1.Text = "5"

End Sub

Private Sub Command7_Click()

Text1.Text = "2"

End Sub

Private Sub Command9_Click()

Text1.Text = "9"

End Sub

Private Sub Command8_Click()

data2 = Val(Text1.Text)

If (OperatorState = 1) Then

result = data1 + data2

End If

If (OperatorState = 2) Then

result = data1 - data2

End If

If (OperatorState = 3) Then

result = data1 * data2

End If

If (OperatorState = 4) Then

result = data1 / data2

End If

Text1.Text = Str(result)

End Sub