|
Public Class Form1
Dim sn As String, num As Integer
Dim flag As Boolean, flag1 As Boolean
Dim flagcode As Integer
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
Select Case flagcode '运算等号判断过程
Case 1
sn = sn + Val(textbox1.Text)
Case 2
sn = sn - Val(textbox1.Text)
Case 3
sn = sn * Val(textbox1.Text)
Case 4
sn = sn / Val(textbox1.Text)
End Select
textbox1.Text = sn
End Sub
Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
Dim back As String
back = textbox1.Text '退格
If Len(back) > 1 Then
textbox1.Text = Mid(back, 1, Len(back) - 1)
Else
textbox1.Text = ""
End If
End Sub
Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
Dim clean As Boolean '清空
textbox1.Text = ""
sn = 0
clean = False
flag = False
End Sub
Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button19.Click
If textbox1.Text = "" Then textbox1.Text = "0."
If InStr(textbox1.Text, ".") = 0 Then '小数点,查找有没有小数点
textbox1.Text = textbox1.Text & "."
flag = False
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' If flag1 = True Then
'textbox1.Text = "0不能为除数" 这个失败了,
If textbox1.Text = "" Then
textbox1.Text = "0"
flag = True
Else
If Mid(textbox1.Text, 1, 1) = "0" Then
If Mid(textbox1.Text, 2, 1) = "." Then
textbox1.Text = textbox1.Text & "0"
End If
Else
textbox1.Text = textbox1.Text & "0"
End If
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If flag = True Then
textbox1.Text = textbox1.Text
Else
textbox1.Text = textbox1.Text & "1"
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If flag = True Then
textbox1.Text = textbox1.Text
Else
textbox1.Text = textbox1.Text & "2"
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If flag = True Then
textbox1.Text = textbox1.Text
Else
textbox1.Text = textbox1.Text & "3"
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
If flag = True Then
textbox1.Text = textbox1.Text
Else
textbox1.Text = textbox1.Text & "4"
End If
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
If flag = True Then
textbox1.Text = textbox1.Text
Else
textbox1.Text = textbox1.Text & "5"
End If
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
If flag = True Then
textbox1.Text = textbox1.Text
Else
textbox1.Text = textbox1.Text & "6"
End If
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
If flag = True Then
textbox1.Text = textbox1.Text
Else
textbox1.Text = textbox1.Text & "7"
End If
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
If flag = True Then
textbox1.Text = textbox1.Text
Else
textbox1.Text = textbox1.Text & "8"
End If
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
If flag = True Then
textbox1.Text = textbox1.Text
Else
textbox1.Text = textbox1.Text & "9"
End If
End Sub
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
sn = textbox1.Text '加号
textbox1.Text = ""
flagcode = 1
End Sub
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
sn = textbox1.Text '减号
textbox1.Text = ""
flagcode = 2
End Sub
Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
sn = textbox1.Text '乘号
textbox1.Text = ""
flagcode = 3
End Sub
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
sn = textbox1.Text '除号
textbox1.Text = ""
flagcode = 4
flag1 = True'用来记录安了除号,不成功~~~
End Sub
Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click
End
End Sub
Private Sub Button20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button21.Click
sn = textbox1.Text '平方
textbox1.Text = sn * Val(textbox1.Text)
End Sub
Private Sub Button22_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button22.Click
sn = textbox1.Text
If textbox1.Text < 0 Then
textbox1.Text = "负数不能开方"
Else
textbox1.Text = "我不懂算``^_^``嬉嬉" 'sn / Val(textbox1.Text) '开方运算,哈哈,不懂了``
End If
End Sub
Private Sub Button23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button23.Click
If textbox1.Text = "0" Then
textbox1.Text = "0没有倒数"
Else
textbox1.Text = 1 / Val(textbox1.Text) '倒数
flagcode = 7
End If
End Sub
Private Sub Button20_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button20.Click
If textbox1.Text = "" Then
textbox1.Text = "-"
Else
textbox1.Text = (-1) * Val(textbox1.Text)
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
有谁懂得的,帮改一下``:handshake :handshake :handshake |
|