📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form frm_calculate
Caption = "计算器V1.0"
ClientHeight = 3105
ClientLeft = 165
ClientTop = 855
ClientWidth = 3900
LinkTopic = "Form1"
ScaleHeight = 3105
ScaleWidth = 3900
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command10
Caption = "="
Height = 615
Left = 3120
TabIndex = 19
Top = 2280
Width = 615
End
Begin VB.CommandButton Command9
Caption = "/"
Height = 615
Left = 3120
TabIndex = 18
Top = 1680
Width = 615
End
Begin VB.CommandButton Command8
Caption = "*"
Height = 615
Left = 2520
TabIndex = 17
Top = 2280
Width = 615
End
Begin VB.CommandButton Command7
Caption = "-"
Height = 615
Left = 2520
TabIndex = 16
Top = 1680
Width = 615
End
Begin VB.CommandButton Command6
Caption = "+"
Height = 615
Left = 2520
TabIndex = 15
Top = 1080
Width = 615
End
Begin VB.CommandButton Command5
Caption = "."
Height = 615
Left = 1920
TabIndex = 14
Top = 2280
Width = 615
End
Begin VB.CommandButton Command4
Caption = "+/-"
Height = 615
Left = 1920
TabIndex = 13
Top = 1080
Width = 615
End
Begin VB.CommandButton Command3
Caption = "退格"
Height = 375
Left = 120
TabIndex = 12
Top = 600
Width = 3615
End
Begin VB.CommandButton Command2
Caption = "CE"
Height = 615
Left = 3120
TabIndex = 11
Top = 1080
Width = 615
End
Begin VB.CommandButton Command1
Caption = "9"
Height = 615
Index = 9
Left = 1320
TabIndex = 10
Top = 2280
Width = 615
End
Begin VB.CommandButton Command1
Caption = "8"
Height = 615
Index = 8
Left = 720
TabIndex = 9
Top = 2280
Width = 615
End
Begin VB.CommandButton Command1
Caption = "7"
Height = 615
Index = 7
Left = 120
TabIndex = 8
Top = 2280
Width = 615
End
Begin VB.CommandButton Command1
Caption = "6"
Height = 615
Index = 6
Left = 1320
TabIndex = 7
Top = 1680
Width = 615
End
Begin VB.CommandButton Command1
Caption = "5"
Height = 615
Index = 5
Left = 720
TabIndex = 6
Top = 1680
Width = 615
End
Begin VB.CommandButton Command1
Caption = "4"
Height = 615
Index = 4
Left = 120
TabIndex = 5
Top = 1680
Width = 615
End
Begin VB.CommandButton Command1
Caption = "3"
Height = 615
Index = 3
Left = 1320
TabIndex = 4
Top = 1080
Width = 615
End
Begin VB.CommandButton Command1
Caption = "2"
Height = 615
Index = 2
Left = 720
TabIndex = 3
Top = 1080
Width = 615
End
Begin VB.CommandButton Command1
Caption = "1"
Height = 615
Index = 1
Left = 120
TabIndex = 2
Top = 1080
Width = 615
End
Begin VB.CommandButton Command1
Caption = "0"
Height = 615
Index = 0
Left = 1920
TabIndex = 1
Top = 1680
Width = 615
End
Begin VB.TextBox Text1
Alignment = 1 'Right Justify
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 120
TabIndex = 0
Top = 120
Width = 3615
End
Begin VB.Menu file
Caption = "文件(&F)"
Begin VB.Menu quit
Caption = "退出"
Shortcut = ^Q
End
End
Begin VB.Menu edit
Caption = "编缉(&E)"
Begin VB.Menu copy
Caption = "复制"
Shortcut = ^C
End
Begin VB.Menu pase
Caption = "粘贴"
Shortcut = ^V
End
Begin VB.Menu cut
Caption = "剪切"
Shortcut = ^X
End
End
End
Attribute VB_Name = "frm_calculate"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim sum As Double
Dim flag As Integer
Private Sub Command1_Click(Index As Integer)
If Text1.Text = "0" Then
Text1.Text = Index
Else
Text1.Text = Text1.Text & Index
End If
End Sub
Private Sub Command10_Click()
Select Case (flag)
Case 1
Text1.Text = sum + Text1.Text
Case 2
Text1.Text = sum - Text1.Text
Case 3
Text1.Text = sum * Text1.Text
Case 4
If Text1.Text = 0 Then
df = MsgBox("除数不能为零!请重新输入.", vbOKOnly + vbInformation, "警告")
Exit Sub
Else
Text1.Text = sum / Text1.Text
End If
End Select
End Sub
Private Sub Command2_Click()
Text1.Text = 0
For Index = 0 To 9
Command1(Index).Visible = True
Next
End Sub
Private Sub Command3_Click()
If Len(Text1.Text) = 1 Then
Text1.Text = 0
Else
If Text1.Text <> "" Then Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
End If
End Sub
Private Sub Command4_Click()
Text1.Text = Text1.Text * -1
End Sub
Private Sub Command5_Click()
If InStr(Text1.Text, ".") = 0 Then
Text1.Text = Text1.Text & "."
Else
Exit Sub
End If
End Sub
Private Sub Command6_Click()
sum = Text1.Text
flag = 1
Text1.Text = 0
End Sub
Private Sub Command7_Click()
sum = Text1.Text
flag = 2
Text1.Text = 0
End Sub
Private Sub Command8_Click()
sum = Text1.Text
flag = 3
Text1.Text = 0
End Sub
Private Sub Command9_Click()
sum = Text1.Text
flag = 4
Text1.Text = 0
End Sub
Private Sub copy_Click()
Clipboard.SetText Form1.Text1.SelText, 1
'把当前选中数据复制到剪贴板上
End Sub
Private Sub cut_Click()
Clipboard.SetText Form1.Text1.SelText, 1
'把当前选中数据复制到剪贴板上
Form1.Text1.SelText = ""
End Sub
Private Sub Form_Load()
Clipboard.Clear
'清空剪贴板
End Sub
Private Sub pase_Click()
i = Form1.Text1.SelStart
str1 = Mid(Form1.Text1.Text, 1, i)
str2 = Mid(Form1.Text1.Text, _
Form1.Text1.SelStart + 1, _
Len(Form1.Text1) - Len(str1))
Form1.Text1 = str1 & Clipboard.GetText & str2
'把剪贴板上的数据粘贴到当前位置处
End Sub
Private Sub quit_Click()
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -