📄 计算器.frm
字号:
Index = 19
Left = 1680
MaskColor = &H00000000&
TabIndex = 8
Top = 2520
Width = 495
End
Begin VB.CommandButton cmdma
Caption = "M+"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 120
TabIndex = 7
Top = 2520
Width = 735
End
Begin VB.CommandButton cmdms
Caption = "MS"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 120
TabIndex = 6
Top = 2040
Width = 735
End
Begin VB.CommandButton cmdmr
Caption = "MR"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 120
TabIndex = 5
Top = 1560
Width = 735
End
Begin VB.CommandButton cmdmc
Caption = "MC"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 120
TabIndex = 4
Top = 1080
Width = 735
End
Begin VB.CommandButton cmdclear
Caption = "C"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3360
TabIndex = 3
Top = 600
Width = 735
End
Begin VB.CommandButton cmdce
Caption = "CE"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2280
TabIndex = 2
Top = 600
Width = 855
End
Begin VB.CommandButton cmdbackspace
BackColor = &H80000000&
Caption = "backspace"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1080
TabIndex = 1
Top = 600
Width = 1095
End
Begin VB.TextBox txtPrint
Alignment = 1 'Right Justify
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 10
TabIndex = 0
Top = 120
Width = 4080
End
Begin VB.Label lbltime
Alignment = 2 'Center
BorderStyle = 1 'Fixed Single
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 315
Left = 2400
TabIndex = 28
Top = 3000
Width = 1725
End
Begin VB.Menu mnuedit
Caption = "Edit"
Index = 12
Begin VB.Menu mnuoperate
Caption = "Copy(&C)"
Index = 0
Shortcut = ^C
End
Begin VB.Menu mnuoperate
Caption = "Paster(&P)"
Index = 1
Shortcut = ^V
End
End
Begin VB.Menu mnuview
Caption = "View"
Index = 20
Begin VB.Menu mnustandard
Caption = "Standard(&S)"
Index = 21
End
Begin VB.Menu mnuprofession
Caption = "Profession(&T)"
Index = 22
End
End
Begin VB.Menu mnuhelp
Caption = "Help"
Index = 30
Begin VB.Menu mnucontents
Caption = "Contents(&H)"
Index = 31
Shortcut = {F1}
End
Begin VB.Menu mnuabout
Caption = "About calculator(&A)"
Index = 32
End
End
Begin VB.Menu mnuexit
Caption = "Exit"
Index = 40
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function GetSystemDefaultLCID Lib "kernel32" () As Long
Dim lang As String
Dim firstdigit As Double
Dim seconddigit As Double
Dim digit As Integer
Dim chose As Integer
Dim account As String
Private Sub cmdaccount_Click(Index As Integer)
firstdigit = txtPrint.Text
Select Case Index
Case 11
account = "/"
chose = 1
Case 12
account = "*"
chose = 1
Case 13
account = "-"
chose = 1
Case 14
account = "+"
chose = 1
Case 15
account = "sqrt"
If txtPrint.Text < 0 Then
MsgBox "被开方的值不能小于零", vbInformation + vbOKOnly, "错误提示"
Else
txtPrint.Text = Sqr(txtPrint.Text)
End If
Case 16
txtPrint.Text = txtPrint.Text / 100
Case 17
If txtPrint.Text = 0 Then
MsgBox "零没有倒数", vbInformation + vbOKOnly, "错误提示"
Else
txtPrint.Text = 1 / txtPrint.Text
End If
End Select
End Sub
Private Sub cmdce_Click()
txtPrint.Text = "0."
End Sub
Private Sub cmdclear_Click()
txtPrint.Text = "0."
firstdigit = 0
seconddigit = 0
account = ""
End Sub
Private Sub cmdclear_KeyPress(KeyAscii As Integer)
txtPrint.Text = ""
End Sub
Private Sub Cmddigit_Click(Index As Integer)
If chose = 1 Then
chose = 0
txtPrint.Text = 0
End If
Select Case Index
Case 0
txtPrint.Text = (txtPrint.Text * 10) + 0 & "."
Case 1
cmddigit(1).Caption = "1"
'txtPrint.Text = "1"
txtPrint.Text = (txtPrint.Text * 10) + 1 & "."
Case 2
cmddigit(2).Caption = "2"
'txtPrint.Text = "2"
txtPrint.Text = (txtPrint.Text * 10) + 2 & "."
Case 3
cmddigit(3).Caption = "3"
'txtPrint.Text = "3"
txtPrint.Text = (txtPrint.Text * 10) + 3 & "."
Case 4
cmddigit(4).Caption = "4"
'txtPrint.Text = "4"
txtPrint.Text = (txtPrint.Text * 10) + 4 & "."
Case 5
cmddigit(5).Caption = "5"
'txtPrint.Text = "5"
txtPrint.Text = (txtPrint.Text * 10) + 5 & "."
Case 6
cmddigit(6).Caption = "6"
'txtPrint.Text = "6"
txtPrint.Text = (txtPrint.Text * 10) + 6 & "."
Case 7
cmddigit(7).Caption = "7"
'txtPrint.Text = "7"
txtPrint.Text = (txtPrint.Text * 10) + 7 & "."
Case 8
cmddigit(8).Caption = "8"
'txtPrint.Text = "8"
txtPrint.Text = (txtPrint.Text * 10) + 8 & "."
Case 9
cmddigit(9).Caption = "9"
'txtPrint.Text = "9"
txtPrint.Text = (txtPrint.Text * 10) + 9 & "."
Case 19
If txtPrint.Text < 0 Then
txtPrint.Text = Abs(txtPrint.Text)
Else
txtPrint.Text = 0 - txtPrint.Text
End If
End Select
End Sub
Private Sub cmdresult_Click(Index As Integer)
Select Case account
Case "/"
seconddigit = txtPrint.Text
If seconddigit = 0 Then
MsgBox "除数不能为零", vbInformation + vbOKOnly, "错误提示"
Else
txtPrint.Text = firstdigit / seconddigit
account = ""
End If
Case "*"
seconddigit = txtPrint.Text
txtPrint.Text = firstdigit * seconddigit
account = ""
Case "-"
seconddigit = txtPrint.Text
txtPrint.Text = firstdigit - seconddigit
account = ""
Case "+"
seconddigit = txtPrint.Text
txtPrint.Text = firstdigit + seconddigit
account = ""
End Select
End Sub
Private Sub Form_Load()
txtPrint.Text = "0."
Dim LocaleID As Long
LocaleID = GetSystemDefaultLCID
Select Case LocaleID
Case &H404
MsgBox "当前系统为:中文繁体", , "语言"
Case &H804
MsgBox "当前系统为:中文简体", , "语言"
lang = "1"
Case &H409
MsgBox "当前系统为:英文", , "语言"
lang = "2"
End Select
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
End If
End Sub
Private Sub mnuoperate_Click(Index As Integer)
Dim intindex As Long
cmdce.Caption = LoadResString(101) '"Add menu" & CStr(intindex)
MsgBox "你点了第" & Index & "个菜单", vbInformation + vbOKOnly, "动态菜单"
End Sub
Private Sub timTimeShow_Timer()
lbltime.Caption = Date & " " & Time()
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -