Public Class Form1
Dim dengyu, yunsuanfu, xiaoshudian, i As Integer, op As String, op1, op2 As Double
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
If TextBox1.Text = "还未输入过任何数!" Or TextBox1.Text = "请输入数!" Or TextBox1.Text = "0" Then
TextBox1.Text = "1"
Else
If dengyu = 0 And yunsuanfu = 0 Then
TextBox1.Text = TextBox1.Text & "1"
Else
TextBox1.Text = "1"
dengyu = 0
yunsuanfu = 0
End If
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dengyu = 0
yunsuanfu = 0
xiaoshudian = 0
op = ""
op1 = 0
TextBox1.Text = "还未输入过任何数!"
End Sub
Private Sub danshuzishuru(ByVal i)
If TextBox1.Text = "还未输入过任何数!" Or TextBox1.Text = "请输入数!" Or TextBox1.Text = "0" Then
TextBox1.Text = i
Else
If dengyu = 0 And yunsuanfu = 0 Then
TextBox1.Text = TextBox1.Text & i
Else
TextBox1.Text = i
dengyu = 0
yunsuanfu = 0
End If
End If
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
danshuzishuru(2)
End Sub
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
danshuzishuru(3)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
danshuzishuru(4)
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
danshuzishuru(5)
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
danshuzishuru(6)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
danshuzishuru(7)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
danshuzishuru(8)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
danshuzishuru(9)
End Sub
Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click
End
End Sub
Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
dengyu = 0
yunsuanfu = 0
xiaoshudian = 0
op = ""
op1 = 0
TextBox1.Text = "还未输入过任何数!"
Label4.Text = "状态正常"
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If TextBox1.Text = "还未输入过任何数!" Or TextBox1.Text = "请输入数!" Then
TextBox1.Text = "请输入数!"
Else
If yunsuanfu = 0 Then
op1 = TextBox1.Text
Else
op1 = op1
End If
op = "+"
TextBox1.Text = "+"
xiaoshudian = 0
yunsuanfu = 1
End If
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
If TextBox1.Text = "还未输入过任何数!" Or TextBox1.Text = "请输入数!" Then
TextBox1.Text = "请输入数!"
Else
If yunsuanfu = 0 Then
op1 = TextBox1.Text
Else
op1 = op1
End If
op = "-"
TextBox1.Text = "-"
xiaoshudian = 0
yunsuanfu = 1
End If
End Sub
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
If TextBox1.Text = "还未输入过任何数!" Or TextBox1.Text = "请输入数!" Then
TextBox1.Text = "请输入数!"
Else
If yunsuanfu = 0 Then
op1 = TextBox1.Text
Else
op1 = op1
End If
op = "*"
TextBox1.Text = "*"
xiaoshudian = 0
yunsuanfu = 1
End If
End Sub
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
If TextBox1.Text = "还未输入过任何数!" Or TextBox1.Text = "请输入数!" Then
TextBox1.Text = "请输入数!"
Else
If yunsuanfu = 0 Then
op1 = TextBox1.Text
Else
op1 = op1
End If
op = "/"
TextBox1.Text = "/"
xiaoshudian = 0
yunsuanfu = 1
End If
End Sub
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
If TextBox1.Text = "还未输入过任何数!" Or TextBox1.Text = "请输入数!" Or dengyu = 1 Or yunsuanfu = 1 Then
TextBox1.Text = "0."
xiaoshudian = 1
dengyu = 0
yunsuanfu = 0
Else
If xiaoshudian = 0 Then
TextBox1.Text = TextBox1.Text & "."
xiaoshudian = 1
dengyu = 0
yunsuanfu = 0
End If
End If
End Sub
Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
1: Select Case op
Case "+"
TextBox1.Text = op1 + TextBox1.Text
dengyu = 1
xiaoshudian = 0
Case "-"
TextBox1.Text = op1 - TextBox1.Text
dengyu = 1
xiaoshudian = 0
Case "*"
TextBox1.Text = op1 * TextBox1.Text
dengyu = 1
xiaoshudian = 0
Case "/"
If TextBox1.Text = "0" Or TextBox1.Text = "0." Or TextBox1.Text = "/" Then
Label4.Text = "除数不能为0!已经自动清零!"
dengyu = 0
yunsuanfu = 0
xiaoshudian = 0
op = ""
op1 = 0
TextBox1.Text = "还未输入过任何数!"
Else
TextBox1.Text = op1 / TextBox1.Text
dengyu = 1
xiaoshudian = 0
End If
End Select
End Sub
Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
If TextBox1.Text = "还未输入过任何数!" Or TextBox1.Text = "请输入数!" Or dengyu = 1 Or yunsuanfu = 1 Or TextBox1.Text = "0" Then
TextBox1.Text = "0"
dengyu = 0
yunsuanfu = 0
Else
TextBox1.Text = TextBox1.Text & "0"
End If
End Sub
End Class