📄 计算器.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 4725
ClientLeft = 60
ClientTop = 450
ClientWidth = 7170
LinkTopic = "Form1"
ScaleHeight = 4725
ScaleWidth = 7170
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command6
Caption = "退出"
Height = 495
Left = 4200
TabIndex = 19
Top = 3960
Width = 1215
End
Begin VB.CommandButton Command5
Caption = "="
Height = 495
Left = 3000
TabIndex = 18
Top = 3960
Width = 1095
End
Begin VB.CommandButton Command4
Caption = "MOD"
Height = 495
Left = 960
TabIndex = 17
Top = 3960
Width = 975
End
Begin VB.CommandButton Command3
Caption = "清除"
Height = 495
Index = 0
Left = 2040
TabIndex = 16
Top = 3960
Width = 855
End
Begin VB.CommandButton Command1
Caption = "."
Height = 495
Index = 10
Left = 4560
TabIndex = 15
Top = 1560
Width = 615
End
Begin VB.CommandButton Command2
Caption = "/"
Height = 495
Index = 3
Left = 4560
TabIndex = 14
Top = 2520
Width = 615
End
Begin VB.CommandButton Command2
Caption = "*"
Height = 495
Index = 2
Left = 3960
TabIndex = 13
Top = 2520
Width = 615
End
Begin VB.CommandButton Command2
Caption = "-"
Height = 495
Index = 1
Left = 4560
TabIndex = 12
Top = 2040
Width = 615
End
Begin VB.CommandButton Command2
Caption = "+"
Height = 495
Index = 0
Left = 3960
TabIndex = 11
Top = 2040
Width = 615
End
Begin VB.CommandButton Command1
Caption = "9"
Height = 495
Index = 9
Left = 1920
TabIndex = 10
Top = 2400
Width = 615
End
Begin VB.CommandButton Command1
Caption = "8"
Height = 495
Index = 8
Left = 1320
TabIndex = 9
Top = 2400
Width = 615
End
Begin VB.CommandButton Command1
Caption = "7"
Height = 495
Index = 7
Left = 720
TabIndex = 8
Top = 2400
Width = 615
End
Begin VB.CommandButton Command1
Caption = "6"
Height = 495
Index = 6
Left = 1920
TabIndex = 7
Top = 1920
Width = 615
End
Begin VB.CommandButton Command1
Caption = "5"
Height = 495
Index = 5
Left = 1320
TabIndex = 6
Top = 1920
Width = 615
End
Begin VB.CommandButton Command1
Caption = "4"
Height = 495
Index = 4
Left = 720
TabIndex = 5
Top = 1920
Width = 615
End
Begin VB.CommandButton Command1
Caption = "3"
Height = 495
Index = 3
Left = 1920
TabIndex = 4
Top = 1440
Width = 615
End
Begin VB.CommandButton Command1
Caption = "2"
Height = 495
Index = 2
Left = 1320
TabIndex = 3
Top = 1440
Width = 615
End
Begin VB.CommandButton Command1
Caption = "1"
Height = 495
Index = 1
Left = 720
TabIndex = 2
Top = 1440
Width = 615
End
Begin VB.CommandButton Command1
Caption = "0"
Height = 495
Index = 0
Left = 3960
TabIndex = 1
Top = 1560
Width = 615
End
Begin VB.TextBox Text1
Height = 495
Left = 960
TabIndex = 0
Top = 600
Width = 4215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim a As Integer, b As Integer, c As Integer
Dim s As String
Private Sub Command1_Click(Index As Integer)
If Index = 10 Then
Text1.Text = Text1.Text & "."
Else: Text1.Text = Text1 & CStr(Index)
End If
If Index = 0 And Left(Text1, 2) <> "." Then
Text1 = Mid(Text1, 2)
End If
End Sub
Private Sub Command2_Click(Index As Integer)
a = Val(Text1.Text)
b = Index
Text1.Text = ""
End Sub
Private Sub Command3_Click(Index As Integer)
Text1.Text = ""
a = 0
End Sub
Private Sub Command5_Click()
c = Val(Text1.Text)
Select Case b
Case 0
Text1.Text = Str(a + c)
Case 1
Text1.Text = Str(a - c)
Case 2
Text1.Text = Str(a * c)
Case 3
If c <> 0 Then
Text1.Text = Str(a / c)
Else
Text1.Text = "除数为0"
End If
End Select
End Sub
Private Sub Command6_Click()
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -