📄 例2-22.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3555
ClientLeft = 60
ClientTop = 345
ClientWidth = 4215
LinkTopic = "Form1"
ScaleHeight = 3555
ScaleWidth = 4215
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton result
Caption = "="
Height = 495
Left = 2880
TabIndex = 16
Top = 1680
Width = 735
End
Begin VB.CommandButton clear
Caption = "cls"
Height = 495
Left = 2880
TabIndex = 15
Top = 1080
Width = 735
End
Begin VB.CommandButton operator
Caption = "/"
Height = 495
Index = 3
Left = 2880
TabIndex = 14
Top = 2880
Width = 735
End
Begin VB.CommandButton operator
Caption = "x"
Height = 495
Index = 2
Left = 2880
TabIndex = 13
Top = 2280
Width = 735
End
Begin VB.CommandButton operator
Caption = "-"
Height = 495
Index = 1
Left = 2040
TabIndex = 12
Top = 2880
Width = 735
End
Begin VB.CommandButton operator
Caption = "+"
Height = 495
Index = 0
Left = 1200
TabIndex = 11
Top = 2880
Width = 735
End
Begin VB.CommandButton number
Caption = "5"
Height = 495
Index = 5
Left = 2040
TabIndex = 10
Top = 1680
Width = 495
End
Begin VB.CommandButton number
Caption = "4"
Height = 495
Index = 4
Left = 1320
TabIndex = 9
Top = 1680
Width = 495
End
Begin VB.CommandButton number
Caption = "3"
Height = 495
Index = 3
Left = 600
TabIndex = 8
Top = 1680
Width = 495
End
Begin VB.CommandButton number
Caption = "9"
Height = 495
Index = 9
Left = 600
TabIndex = 7
Top = 2880
Width = 495
End
Begin VB.CommandButton number
Caption = "8"
Height = 495
Index = 8
Left = 2040
TabIndex = 6
Top = 2280
Width = 495
End
Begin VB.CommandButton number
Caption = "7"
Height = 495
Index = 7
Left = 1320
TabIndex = 5
Top = 2280
Width = 495
End
Begin VB.CommandButton number
Caption = "6"
Height = 495
Index = 6
Left = 600
TabIndex = 4
Top = 2280
Width = 495
End
Begin VB.CommandButton number
Caption = "2"
Height = 495
Index = 2
Left = 2040
TabIndex = 3
Top = 1080
Width = 495
End
Begin VB.CommandButton number
Caption = "1"
Height = 495
Index = 1
Left = 1320
TabIndex = 2
Top = 1080
Width = 495
End
Begin VB.CommandButton number
Caption = "0"
Height = 495
Index = 0
Left = 600
TabIndex = 1
Top = 1080
Width = 495
End
Begin VB.Label dataout
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 615
Left = 600
TabIndex = 0
Top = 120
Width = 2895
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim op1 As Byte '用来记录前面输入的操作符
Dim ops1&, ops2& '两个操作数
Dim res As Boolean '标志是否已算出结果
Private Sub Clear_Click()
dataout.Caption = " "
End Sub
Private Sub Form_Load()
res = False
End Sub
'按下数字键0~9的事件过程
Private Sub number_Click(i1 As Integer)
If Not res Then
dataout.Caption = dataout.Caption & i1
Else
dataout.Caption = i1
res = False
End If
End Sub
'按下操作键+、-、ⅹ、∕的事件过程
Private Sub Operator_Click(i2 As Integer)
ops1 = dataout.Caption
op1 = i2 '记下对应的操作符
dataout.Caption = " "
End Sub
'按下"="键的事件过程
Private Sub result_Click()
ops2 = dataout.Caption
Select Case op1
Case 0
dataout.Caption = ops1 + ops2
Case 1
dataout.Caption = ops1 - ops2
Case 2
dataout.Caption = ops1 * ops2
Case 3
dataout.Caption = ops1 / ops2
End Select
res = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -