📄 form1.frm
字号:
sign = Sgn(result)
End If
End Sub
Private Sub Command15_Click()
If compute = 0 Then Text1.Text = Text1.Text + "a"
If compute = 4 Then Text1.Text = "a"
compute = 0
End Sub
Private Sub Command16_Click()
If compute = 0 Then Text1.Text = Text1.Text + "s"
If compute = 4 Then Text1.Text = "s"
compute = 0
End Sub
Private Sub Command17_Click()
If compute = 0 Then Text1.Text = Text1.Text + "d"
If compute = 4 Then Text1.Text = "d"
compute = 0
End Sub
Private Sub Command18_Click()
If compute = 0 Then Text1.Text = Text1.Text + "f"
If compute = 4 Then Text1.Text = "f"
compute = 0
End Sub
Private Sub Command19_Click()
If compute = 0 Then Text1.Text = Text1.Text + "g"
If compute = 4 Then Text1.Text = "g"
compute = 0
End Sub
Private Sub Command2_Click()
If compute = 1 Or compute = 2 Then
If (Val(Text1.Text) > 0) Then
Text1.Text = Sqr(Val(Text1.Text))
poi = 0
compute = 2
Else
Text1.Text = "注意:负数不能开根号!请按复位键重新开始。"
compute = 3
End If
End If
End Sub
Private Sub Command20_Click()
If compute = 0 Then Text1.Text = Text1.Text + "h"
If compute = 4 Then Text1.Text = "h": compute = 0
If compute = 1 Then
If Text1.Text = "0" Then Text1.Text = "4" Else Text1.Text = Text1.Text + "4"
End If
If compute = 2 Then
Text1.Text = "4"
compute = 1
sign = 1
End If
End Sub
Private Sub Command21_Click()
If compute = 0 Then Text1.Text = Text1.Text + "j"
If compute = 4 Then Text1.Text = "j": compute = 0
If compute = 1 Then
If Text1.Text = "0" Then Text1.Text = "5" Else Text1.Text = Text1.Text + "5"
End If
If compute = 2 Then
Text1.Text = "5"
compute = 1
sign = 1
End If
End Sub
Private Sub Command22_Click()
If compute = 0 Then Text1.Text = Text1.Text + "k"
If compute = 4 Then Text1.Text = "k": compute = 0
If compute = 1 Then
If Text1.Text = "0" Then Text1.Text = "6" Else Text1.Text = Text1.Text + "6"
End If
If compute = 2 Then
Text1.Text = "6"
compute = 1
sign = 1
End If
End Sub
Private Sub Command23_Click()
If compute = 0 Then Text1.Text = Text1.Text + "l"
If compute = 4 Then Text1.Text = "l": compute = 0
If compute = 1 Then
Select Case operator '选择运算符运算
Case "", "+"
result = result + Val(Text1.Text)
Case "-"
result = result - Val(Text1.Text)
Case "*"
result = result * Val(Text1.Text)
Case "/"
If Val(Text1.Text) = 0 Then
compute = 3 '设置出错标志'
Text1.Text = "注意:除数不能为0!请按复位键重新开始。"
Else
result = result / Val(Text1.Text)
End If
End Select
operator = "*"
poi = 0
sign = Sgn(result)
If compute = 1 Then
compute = 2
Text1.Text = Str(result)
End If
End If
If compute = 2 Then
operator = "*"
result = Val(Text1.Text)
sign = Sgn(result)
End If
End Sub
Private Sub Command24_Click()
If compute = 0 Then '翻译
If Text1.Text = "a" Then Text1.Text = "a:一个"
If Text1.Text = "apple" Then Text1.Text = "apple:苹果"
'算法可优化
compute = 4
End If
If compute = 1 Then
Select Case operator '选择运算符运算
Case "", "+"
result = result + Val(Text1.Text)
Case "-"
result = result - Val(Text1.Text)
Case "*"
result = result * Val(Text1.Text)
Case "/"
If Val(Text1.Text) = 0 Then
compute = 3 '设置出错标志'
Text1.Text = "注意:除数不能为0!请按复位键重新开始。"
Else
result = result / Val(Text1.Text)
End If
End Select
operator = "/"
poi = 0
sign = Sgn(result)
If compute = 1 Then
compute = 2
Text1.Text = Str(result)
End If
End If
If compute = 2 Then
operator = "/"
result = Val(Text1.Text)
sign = Sgn(result)
End If
End Sub
Private Sub Command25_Click()
If compute = 0 Then Text1.Text = Text1.Text + "z"
If compute = 4 Then Text1.Text = "z"
compute = 0
End Sub
Private Sub Command26_Click()
If compute = 0 Then Text1.Text = Text1.Text + "x"
If compute = 4 Then Text1.Text = "x"
compute = 0
End Sub
Private Sub Command27_Click()
If compute = 0 Then Text1.Text = Text1.Text + "c"
If compute = 4 Then Text1.Text = "c"
compute = 0
End Sub
Private Sub Command28_Click()
If compute = 0 Then Text1.Text = Text1.Text + "v"
If compute = 4 Then Text1.Text = "v"
compute = 0
End Sub
Private Sub Command29_Click()
If compute = 0 Then Text1.Text = Text1.Text + "b"
If compute = 4 Then Text1.Text = "b"
compute = 0
End Sub
Private Sub Command3_Click()
compute = 1
poi = 0
sign = 1
operator = ""
result = 0
Text1.Text = "0"
Text1.Alignment = 1
Command5.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Command8.Enabled = False
Command9.Enabled = False
Command15.Enabled = False
Command16.Enabled = False
Command17.Enabled = False
Command18.Enabled = False
Command19.Enabled = False
Command25.Enabled = False
Command26.Enabled = False
Command27.Enabled = False
Command28.Enabled = False
Command29.Enabled = False
Command10.Caption = "7"
Command11.Caption = "8"
Command12.Caption = "9"
Command13.Caption = "+"
Command14.Caption = "-"
Command20.Caption = "4"
Command21.Caption = "5"
Command22.Caption = "6"
Command23.Caption = "×"
Command24.Caption = "÷"
Command30.Caption = "1"
Command31.Caption = "2"
Command32.Caption = "3"
Command33.Caption = "0"
Command37.Caption = "."
End Sub
Private Sub Command30_Click()
If compute = 0 Then Text1.Text = Text1.Text + "n"
If compute = 4 Then Text1.Text = "n": compute = 0
If compute = 1 Then
If Text1.Text = "0" Then Text1.Text = "1" Else Text1.Text = Text1.Text + "1"
End If
If compute = 2 Then
Text1.Text = "1"
compute = 1
sign = 1
End If
End Sub
Private Sub Command31_Click()
If compute = 0 Then Text1.Text = Text1.Text + "m"
If compute = 4 Then Text1.Text = "m": compute = 0
If compute = 1 Then
If Text1.Text = "0" Then Text1.Text = "2" Else Text1.Text = Text1.Text + "2"
End If
If compute = 2 Then
Text1.Text = "2"
compute = 1
sign = 1
End If
End Sub
Private Sub Command32_Click()
If compute = 0 Then Text1.Text = Text1.Text + " "
If compute = 1 Then
If Text1.Text = "0" Then Text1.Text = "3" Else Text1.Text = Text1.Text + "3"
End If
If compute = 2 Then
Text1.Text = "3"
compute = 1
sign = 1
End If
End Sub
Private Sub Command33_Click()
If compute = 1 Then
If Text1.Text = "0" Then Text1.Text = "0" Else Text1.Text = Text1.Text + "0"
End If
If compute = 2 Then
Text1.Text = "0"
compute = 1
sign = 1
End If
End Sub
Private Sub Command34_Click()
Dim length As Single
length = Len(Text1.Text)
If compute = 0 Then
If length <> 0 Then Text1.Text = Left(Text1.Text, length - 1) '减少最右边一个字符
End If
If (compute = 1 Or compute = 2) Then
If ((length = 2 And sign = -1) Or length = 1) Then
Text1.Text = "0"
sign = 1
ElseIf length > 1 Then
If Mid(Text1.Text, length - 1, 1) = "." Then
Text1.Text = Left(Text1.Text, length - 2)
poi = 0
ElseIf Mid(Text1.Text, length, 1) = "." Then
Text1.Text = Left(Text1.Text, length - 1)
poi = 0
Else
Text1.Text = Left(Text1.Text, length - 1)
End If
End If
compute = 1
End If
End Sub
Private Sub Command35_Click()
If (compute <> 0 And Text1.Text <> "0" And compute <> 3) Then
If sign = 1 Then Text1.Text = "-" + Text1.Text
If sign = -1 Then Text1.Text = Right(Text1.Text, Len(Text1.Text) - 1)
sign = sign * -1
End If
End Sub
Private Sub Command36_Click()
If compute = 1 Then
Select Case operator '选择运算符运算
Case "", "+"
result = result + Val(Text1.Text)
Case "-"
result = result - Val(Text1.Text)
Case "*"
result = result * Val(Text1.Text)
Case "/"
If Val(Text1.Text) = 0 Then
compute = 3 '设置出错标志'
Text1.Text = "注意:除数不能为0!请按复位键重新开始。"
Else
result = result / Val(Text1.Text)
End If
End Select
'按等号后重新初始化
operator = ""
poi = 0
sign = Sgn(result)
If compute = 1 Then
compute = 2
Text1.Text = Str(result)
End If
result = 0
End If
End Sub
Private Sub Command37_Click()
If compute = 1 Then
If poi = 0 Then
Text1.Text = Text1.Text + "."
poi = 1
End If
End If
If compute = 2 Then
Text1.Text = "0."
poi = 1
compute = 1
sign = 1
End If
End Sub
Private Sub Command38_Click()
If compute = 0 Or compute = 4 Then
Text1.Text = ""
compute = 0
End If
If compute = 1 Or compute = 2 Or compute = 3 Then
compute = 1
poi = 0
sign = 1
operator = ""
result = 0
Text1.Text = "0"
End If
End Sub
Private Sub Command39_Click()
If compute = 1 Or compute = 2 Then Text1.Text = "3.14159265358979": compute = 2
End Sub
Private Sub Command4_Click()
Unload Me
End Sub
Private Sub Command41_Click()
If compute = 1 Or compute = 2 Then Text1.Text = Sin(Val(Text1.Text)): compute = 2
End Sub
Private Sub Command42_Click()
If compute = 1 Or compute = 2 Then Text1.Text = Cos(Val(Text1.Text)): compute = 2
End Sub
Private Sub Command43_Click()
If compute = 1 Or compute = 2 Then
If Text1.Text <> 0 Then
Text1.Text = 1 / (Val(Text1.Text))
compute = 2
Else
Text1.Text = "注意:除数不能为0!请按复位键重新开始。"
compute = 3 '设置出错标志'
End If
End If
End Sub
Private Sub Command5_Click()
If compute = 0 Then Text1.Text = Text1.Text + "q"
If compute = 4 Then Text1.Text = "q"
compute = 0
End Sub
Private Sub Command6_Click()
If compute = 0 Then Text1.Text = Text1.Text + "w"
If compute = 4 Then Text1.Text = "w"
compute = 0
End Sub
Private Sub Command7_Click()
If compute = 0 Then Text1.Text = Text1.Text + "e"
If compute = 4 Then Text1.Text = "e"
compute = 0
End Sub
Private Sub Command8_Click()
If compute = 0 Then Text1.Text = Text1.Text + "r"
If compute = 4 Then Text1.Text = "r"
compute = 0
End Sub
Private Sub Command9_Click()
If compute = 0 Then Text1.Text = Text1.Text + "t"
If compute = 4 Then Text1.Text = "t"
compute = 0
End Sub
Private Sub Form_Load()
compute = 0
Width = 6900
Height = 4900
Left = Screen.Width \ 2 - 4100
Top = (Screen.Height - Height) \ 2 - 1000
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -