vb.net简单的计算器实现
作者:互联网
vb.net简单的计算器实现
效果图
1首先我们需要把控件都摆好.
2处理0~9按钮事件
'按钮0~9
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If stat = 1 Then
TextBox1.Text = 0
stat = 0
End If
If TextBox1.Text = "0" Then
TextBox1.Text = "1"
Else
TextBox1.Text = TextBox1.Text + "1"
End If
End Sub
3处理加减乘除按钮事件
'按钮加减乘除
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
sign = "+"
one = TextBox1.Text
TextBox1.Text = 0
End Sub
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
sign = "-"
one = TextBox1.Text
TextBox1.Text = 0
End Sub
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
sign = "*"
one = TextBox1.Text
TextBox1.Text = 0
End Sub
Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
sign = "/"
one = TextBox1.Text
TextBox1.Text = 0
End Sub
4处理=按钮事件
'按钮等于号
Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
two = TextBox1.Text
If sign = "+" Then
add()
End If
If sign = "-" Then
minus()
End If
If sign = "*" Then
multiply()
End If
If sign = "/" Then
divide()
End If
End Sub
标签:vb,End,Sub,Text,ByVal,System,TextBox1,计算器,net 来源: https://blog.csdn.net/weixin_57171554/article/details/115801299