⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 计算器
💻 FRM
📖 第 1 页 / 共 3 页
字号:
         Left            =   3705
         TabIndex        =   18
         Top             =   2610
         Width           =   495
      End
      Begin VB.CommandButton Command21 
         Caption         =   "J"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   4230
         TabIndex        =   17
         Top             =   2610
         Width           =   495
      End
      Begin VB.CommandButton Command22 
         Caption         =   "K"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   4755
         TabIndex        =   16
         Top             =   2610
         Width           =   495
      End
      Begin VB.CommandButton Command23 
         Caption         =   "L"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   5295
         TabIndex        =   15
         Top             =   2610
         Width           =   495
      End
      Begin VB.CommandButton Command24 
         Caption         =   "Enter"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   5280
         TabIndex        =   14
         Top             =   3090
         Width           =   1035
      End
      Begin VB.CommandButton Command25 
         Caption         =   "Z"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   1050
         TabIndex        =   13
         Top             =   3090
         Width           =   495
      End
      Begin VB.CommandButton Command26 
         Caption         =   "X"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   1578
         TabIndex        =   12
         Top             =   3090
         Width           =   495
      End
      Begin VB.CommandButton Command27 
         Caption         =   "C"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   2106
         TabIndex        =   11
         Top             =   3090
         Width           =   495
      End
      Begin VB.CommandButton Command28 
         Caption         =   "V"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   2634
         TabIndex        =   10
         Top             =   3090
         Width           =   495
      End
      Begin VB.CommandButton Command29 
         Caption         =   "B"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   3162
         TabIndex        =   9
         Top             =   3090
         Width           =   495
      End
      Begin VB.CommandButton Command30 
         Caption         =   "N"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   3690
         TabIndex        =   8
         Top             =   3090
         Width           =   495
      End
      Begin VB.CommandButton Command31 
         Caption         =   "M"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   4218
         TabIndex        =   7
         Top             =   3090
         Width           =   495
      End
      Begin VB.CommandButton Command32 
         Caption         =   "Spa"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   4746
         TabIndex        =   6
         Top             =   3090
         Width           =   495
      End
      Begin VB.CommandButton Command35 
         Caption         =   "+/-"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   5820
         TabIndex        =   5
         Top             =   2610
         Width           =   495
      End
      Begin VB.CommandButton Command4 
         Caption         =   "关 闭"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   360
         TabIndex        =   4
         Top             =   2130
         Width           =   615
      End
      Begin VB.CommandButton Command3 
         Caption         =   "计 算"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   360
         TabIndex        =   3
         Top             =   2610
         Width           =   615
      End
      Begin VB.CommandButton Command1 
         Caption         =   "英 汉"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   360
         TabIndex        =   2
         Top             =   3090
         Width           =   615
      End
      Begin VB.TextBox Text1 
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   14.25
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   1215
         Left            =   420
         MultiLine       =   -1  'True
         TabIndex        =   1
         Top             =   600
         Width           =   5775
      End
      Begin VB.Image Image1 
         Height          =   3675
         Left            =   270
         Picture         =   "Form1.frx":0007
         Top             =   390
         Width           =   6120
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public compute As Single '标志:0为英文,1为运算,2为运算结果,3为出错标志,4为翻译
Public poi As Single      '小数点标志
Public sign As Single       '操作数及结果的正负号判断
Public operator As String   '+、-、*、/ 操作运算符
Public result As Double      '运算结果
Private Sub Command1_Click()
compute = 0
Text1.Text = ""
Text1.Alignment = 0

Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = True
Command9.Enabled = True
Command15.Enabled = True
Command16.Enabled = True
Command17.Enabled = True
Command18.Enabled = True
Command19.Enabled = True
Command25.Enabled = True
Command26.Enabled = True
Command27.Enabled = True
Command28.Enabled = True
Command29.Enabled = True

Command10.Caption = "Y"
Command11.Caption = "U"
Command12.Caption = "I"
Command13.Caption = "O"
Command14.Caption = "P"
Command20.Caption = "H"
Command21.Caption = "J"
Command22.Caption = "K"
Command23.Caption = "L"
Command24.Caption = "Enter"
Command30.Caption = "N"
Command31.Caption = "M"
Command32.Caption = "Spa"
End Sub

Private Sub Command10_Click()
If compute = 0 Then Text1.Text = Text1.Text + "y"
If compute = 4 Then Text1.Text = "y": compute = 0

If compute = 1 Then
If Text1.Text = "0" Then Text1.Text = "7" Else Text1.Text = Text1.Text + "7"
End If
If compute = 2 Then
    Text1.Text = "7"
    compute = 1
    sign = 1
End If
End Sub

Private Sub Command11_Click()
If compute = 0 Then Text1.Text = Text1.Text + "u"
If compute = 4 Then Text1.Text = "u": compute = 0

If compute = 1 Then
If Text1.Text = "0" Then Text1.Text = "8" Else Text1.Text = Text1.Text + "8"
End If
If compute = 2 Then
    Text1.Text = "8"
    compute = 1
    sign = 1
End If
End Sub

Private Sub Command12_Click()
If compute = 0 Then Text1.Text = Text1.Text + "i"
If compute = 4 Then Text1.Text = "i": compute = 0

If compute = 1 Then
If Text1.Text = "0" Then Text1.Text = "9" Else Text1.Text = Text1.Text + "9"
End If
If compute = 2 Then
    Text1.Text = "9"
    compute = 1
    sign = 1
End If
End Sub

Private Sub Command13_Click()
If compute = 0 Then Text1.Text = Text1.Text + "o"
If compute = 4 Then Text1.Text = "o": compute = 0

If compute = 1 Then
Select Case operator    '选择运算符运算
Case "", "+"
    result = result + Val(Text1.Text)
Case "-"
    result = result - Val(Text1.Text)
Case "*"
    result = result * Val(Text1.Text)
Case "/"
If Val(Text1.Text) = 0 Then
    compute = 3 '设置出错标志'
    Text1.Text = "注意:除数不能为0!请按复位键重新开始。"
Else
    result = result / Val(Text1.Text)
End If
End Select

    operator = "+"     '做加法  ,下,同理
    poi = 0
    sign = Sgn(result)
If compute = 1 Then
    compute = 2
    Text1.Text = Str(result)
End If
End If
If compute = 2 Then
    operator = "+"
    result = Val(Text1.Text)
    sign = Sgn(result)
End If
End Sub

Private Sub Command14_Click()
If compute = 0 Then Text1.Text = Text1.Text + "p"
If compute = 4 Then Text1.Text = "p": compute = 0

If compute = 1 Then
Select Case operator    '选择运算符运算
Case "", "+"
    result = result + Val(Text1.Text)
Case "-"
    result = result - Val(Text1.Text)
Case "*"
    result = result * Val(Text1.Text)
Case "/"
If Val(Text1.Text) = 0 Then
    compute = 3   '设置出错标志'
    Text1.Text = "注意:除数不能为0!请按复位键重新开始。"
Else
    result = result / Val(Text1.Text)
End If
End Select
    operator = "-"
    poi = 0
    sign = Sgn(result)
If compute = 1 Then
    compute = 2
    Text1.Text = Str(result)
End If
End If
If compute = 2 Then
    operator = "-"
    result = Val(Text1.Text)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -