📄 form3.frm
字号:
VERSION 5.00
Begin VB.Form 计算器
BackColor = &H00FFFF80&
Caption = "计算器"
ClientHeight = 3195
ClientLeft = 3225
ClientTop = 2370
ClientWidth = 4875
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4875
Begin VB.TextBox Text1
Height = 615
Left = 1800
TabIndex = 11
Top = 120
Width = 1575
End
Begin VB.CommandButton Command1
Caption = "计算"
Height = 615
Left = 1800
TabIndex = 9
Top = 960
Width = 2055
End
Begin VB.Frame Frame1
BackColor = &H000000FF&
Caption = "选择计算"
Height = 1500
Left = 200
TabIndex = 5
Top = 130
Width = 1000
Begin VB.OptionButton divideOption4
BackColor = &H000000FF&
Caption = "除"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 300
Left = 0
TabIndex = 10
Top = 1200
Width = 1000
End
Begin VB.OptionButton multiplOption3
BackColor = &H000000FF&
Caption = "乘"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 300
Left = 0
TabIndex = 8
Top = 900
Width = 1000
End
Begin VB.OptionButton minusOption2
BackColor = &H000000FF&
Caption = "减"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 300
Left = 0
TabIndex = 7
Top = 600
Width = 1000
End
Begin VB.OptionButton addoption1
BackColor = &H000000FF&
Caption = "加"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 300
Left = 0
TabIndex = 6
Top = 300
Value = -1 'True
Width = 1000
End
End
Begin VB.TextBox output
Height = 800
Left = 3240
Locked = -1 'True
TabIndex = 4
Top = 2000
Width = 800
End
Begin VB.TextBox input2
Height = 800
Left = 1560
TabIndex = 2
Top = 2000
Width = 800
End
Begin VB.TextBox input1
Height = 800
Left = 120
TabIndex = 0
Top = 1920
Width = 800
End
Begin VB.Label Label2
Alignment = 2 'Center
AutoSize = -1 'True
Caption = "="
Height = 180
Left = 2700
TabIndex = 3
Top = 2205
Width = 220
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "+"
Height = 255
Left = 1080
TabIndex = 1
Top = 2200
Width = 375
End
End
Attribute VB_Name = "计算器"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub addoption1_Click()
Label1.Caption = "+"
output.Text = ""
End Sub
Private Sub Command1_Click()
Dim n1, n2, result As Single
n1 = Val(input1.Text)
n2 = Val(input2.Text)
If addoption1.Value = True Then
result = n1 + n2
End If
If minusOption2.Value = True Then
result = n1 - n2
End If
If multiplOption3.Value = True Then
result = n1 * n2
End If
If divideOption4.Value = True Then
If n2 = 0 Then
MsgBox "除数不能为零"
End
Else
result = n1 / n2
End If
End If
output.Text = result
End Sub
Private Sub divideOption4_Click()
Label1.Caption = "/"
output.Text = ""
End Sub
Private Sub minusOption2_Click()
Label1.Caption = "-"
output.Text = ""
End Sub
Private Sub multiplOption3_Click()
Label1.Caption = "*"
output.Text = ""
End Sub
Private Sub Text1_()
End Sub
Private Sub Text1_Click()
Print addoption1.Value
Print minusOption2.Value
Print multiplOption3.Value
Print divideOption4.Value
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -