📄 计算器.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "四则运算器"
ClientHeight = 3360
ClientLeft = 60
ClientTop = 450
ClientWidth = 4065
LinkTopic = "Form1"
ScaleHeight = 3360
ScaleWidth = 4065
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command17
Caption = "清零"
Height = 375
Left = 3120
TabIndex = 17
Top = 240
Width = 735
End
Begin VB.CommandButton chu
Caption = "/"
Height = 375
Left = 3120
TabIndex = 16
Top = 2760
Width = 735
End
Begin VB.CommandButton eqr
Caption = "="
Height = 375
Left = 2160
TabIndex = 15
Top = 2760
Width = 735
End
Begin VB.CommandButton keypoint
Caption = "."
Height = 375
Left = 1200
TabIndex = 14
Top = 2760
Width = 735
End
Begin VB.CommandButton key0
Caption = "0"
Height = 375
Left = 240
TabIndex = 13
Top = 2760
Width = 735
End
Begin VB.CommandButton cheng
Caption = "*"
Height = 375
Left = 3120
TabIndex = 12
Top = 2160
Width = 735
End
Begin VB.CommandButton key9
Caption = "9"
Height = 375
Left = 2160
TabIndex = 11
Top = 2160
Width = 735
End
Begin VB.CommandButton key8
Caption = "8"
Height = 375
Left = 1200
TabIndex = 10
Top = 2160
Width = 735
End
Begin VB.CommandButton key7
Caption = "7"
Height = 375
Left = 240
TabIndex = 9
Top = 2160
Width = 735
End
Begin VB.CommandButton jian
Caption = "-"
Height = 375
Left = 3120
TabIndex = 8
Top = 1560
Width = 735
End
Begin VB.CommandButton key6
Caption = "6"
Height = 375
Left = 2160
TabIndex = 7
Top = 1560
Width = 735
End
Begin VB.CommandButton key5
Caption = "5"
Height = 375
Left = 1200
TabIndex = 6
Top = 1560
Width = 735
End
Begin VB.CommandButton key4
Caption = "4"
Height = 375
Left = 240
TabIndex = 5
Top = 1560
Width = 735
End
Begin VB.CommandButton keyadd
Caption = "+"
Height = 375
Left = 3120
TabIndex = 4
Top = 960
Width = 735
End
Begin VB.CommandButton key3
Caption = "3"
Height = 375
Left = 2160
TabIndex = 3
Top = 960
Width = 735
End
Begin VB.CommandButton key2
Caption = "2"
Height = 375
Left = 1200
TabIndex = 2
Top = 960
Width = 735
End
Begin VB.CommandButton key1
Caption = "1"
Height = 375
Left = 240
TabIndex = 1
Top = 960
Width = 735
End
Begin VB.TextBox Text1
Alignment = 1 'Right Justify
Height = 375
Left = 240
TabIndex = 0
Text = "0"
Top = 240
Width = 2655
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim x0, x1, x2 As Double
Dim Pointed, NewInput As Boolean
Dim Oper1
Private Sub cheng_Click()
x1 = Text1.Text
Oper1 = 3
NewInput = True
Pointed = False
End Sub
Private Sub chu_Click()
x1 = Text1.Text
Oper1 = 4
NewInput = True
Pointed = False
End Sub
Private Sub Command17_Click()
Text1.Text = "0"
End Sub
Private Sub eqr_Click()
On Error GoTo ErrHdl
x2 = Text1.Text
NewInput = True
Pointed = False
Select Case Oper1
Case 1
Text1.Text = x1 + x2
Case 2
Text1.Text = x1 - x2
Case 3
Text1.Text = x1 * x2
Case 4
Text1.Text = x1 / x2
End Select
Exit Sub
ErrHdl: Text1.Text = "error!"
End Sub
Private Sub jian_Click()
x1 = Text1.Text
Oper1 = 2
NewInput = True
Pointed = False
End Sub
Private Sub key0_Click()
If Text1.Text = "0" Or NewInput Then
Text1.Text = ""
End If
If Text1.Text <> "0" Then
Text1.Text = Text1.Text + "0"
NewInput = False
End If
End Sub
Private Sub key1_Click()
If Text1.Text = "0" Or NewInput Then
Text1.Text = ""
End If
Text1.Text = Text1.Text + "1"
NewInput = False
End Sub
Private Sub key2_Click()
If Text1.Text = "0" Or NewInput Then
Text1.Text = ""
End If
Text1.Text = Text1.Text + "2"
NewInput = False
End Sub
Private Sub key3_Click()
If Text1.Text = "0" Or NewInput Then
Text1.Text = ""
End If
Text1.Text = Text1.Text + "3"
NewInput = False
End Sub
Private Sub key4_Click()
If Text1.Text = "0" Or NewInput Then
Text1.Text = ""
End If
Text1.Text = Text1.Text + "4"
NewInput = False
End Sub
Private Sub key5_Click()
If Text1.Text = "0" Or NewInput Then
Text1.Text = ""
End If
Text1.Text = Text1.Text + "5"
NewInput = False
End Sub
Private Sub key6_Click()
If Text1.Text = "0" Or NewInput Then
Text1.Text = ""
End If
Text1.Text = Text1.Text + "6"
NewInput = False
End Sub
Private Sub key7_Click()
If Text1.Text = "0" Or NewInput Then
Text1.Text = ""
End If
Text1.Text = Text1.Text + "7"
NewInput = False
End Sub
Private Sub key8_Click()
If Text1.Text = "0" Or NewInput Then
Text1.Text = ""
End If
Text1.Text = Text1.Text + "8"
NewInput = False
End Sub
Private Sub key9_Click()
If Text1.Text = "0" Or NewInput Then
Text1.Text = ""
End If
Text1.Text = Text1.Text + "9"
NewInput = False
End Sub
Private Sub keyadd_Click()
x1 = Text1.Text
Oper1 = 1
NewInput = True
Pointed = False
End Sub
Private Sub keypoint_Click()
If Not Pointed Then
Text1.Text = Text1.Text + "."
Pointed = True
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -