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

📄 form2.frm

📁 简单计算器(带密码“111111”) 进行简单的数字计算 包括“+” “-” “*” “/” “乘方”
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form2 
   BackColor       =   &H00C0C0C0&
   Caption         =   "rie的计算器"
   ClientHeight    =   3765
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   2580
   FillColor       =   &H0000FFFF&
   ForeColor       =   &H00FF0000&
   ScaleHeight     =   3765
   ScaleWidth      =   2580
   StartUpPosition =   3  '窗口缺省
   Begin VB.Frame Frame1 
      Height          =   3735
      Left            =   0
      TabIndex        =   1
      Top             =   0
      Width           =   2535
      Begin VB.CommandButton Command4 
         Caption         =   "+/-"
         Height          =   255
         Left            =   1920
         TabIndex        =   22
         Top             =   960
         Width           =   495
      End
      Begin VB.CommandButton Command2 
         Caption         =   "x^y"
         BeginProperty Font 
            Name            =   "黑体"
            Size            =   7.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Index           =   4
         Left            =   1320
         TabIndex        =   20
         Top             =   960
         Width           =   495
      End
      Begin VB.CommandButton Command7 
         Caption         =   "."
         Height          =   495
         Left            =   720
         TabIndex        =   19
         Top             =   3120
         Width           =   495
      End
      Begin VB.CommandButton Command8 
         Caption         =   "AC"
         Height          =   255
         Left            =   120
         TabIndex        =   18
         Top             =   960
         Width           =   495
      End
      Begin VB.CommandButton Command3 
         Caption         =   "="
         Height          =   495
         Left            =   1320
         TabIndex        =   17
         Top             =   3120
         Width           =   495
      End
      Begin VB.CommandButton Command6 
         Caption         =   "OFF"
         Height          =   255
         Left            =   720
         TabIndex        =   16
         Top             =   960
         Width           =   495
      End
      Begin VB.CommandButton Command2 
         Caption         =   "÷"
         BeginProperty Font 
            Name            =   "黑体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   3
         Left            =   1920
         TabIndex        =   15
         Top             =   1320
         Width           =   495
      End
      Begin VB.CommandButton Command2 
         Caption         =   "×"
         BeginProperty Font 
            Name            =   "黑体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   2
         Left            =   1920
         TabIndex        =   14
         Top             =   1920
         Width           =   495
      End
      Begin VB.CommandButton Command2 
         Caption         =   "-"
         BeginProperty Font 
            Name            =   "黑体"
            Size            =   9
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   1
         Left            =   1920
         TabIndex        =   13
         Top             =   2520
         Width           =   495
      End
      Begin VB.CommandButton Command2 
         Caption         =   "+"
         BeginProperty Font 
            Name            =   "黑体"
            Size            =   15
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   0
         Left            =   1920
         TabIndex        =   12
         Top             =   3120
         Width           =   495
      End
      Begin VB.TextBox Text1 
         Alignment       =   1  'Right Justify
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   14.25
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00C00000&
         Height          =   375
         HideSelection   =   0   'False
         Left            =   120
         TabIndex        =   0
         Top             =   240
         Width           =   2295
      End
      Begin VB.CommandButton Command1 
         BackColor       =   &H00FF0000&
         Caption         =   "0"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   0
         Left            =   120
         MaskColor       =   &H00FF0000&
         TabIndex        =   11
         Top             =   3120
         Width           =   495
      End
      Begin VB.CommandButton Command1 
         Caption         =   "1"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   1
         Left            =   120
         MaskColor       =   &H00FF0000&
         TabIndex        =   10
         Top             =   2520
         Width           =   495
      End
      Begin VB.CommandButton Command1 
         Caption         =   "2"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   2
         Left            =   720
         TabIndex        =   9
         Top             =   2520
         Width           =   495
      End
      Begin VB.CommandButton Command1 
         Caption         =   "3"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   3
         Left            =   1320
         TabIndex        =   8
         Top             =   2520
         Width           =   495
      End
      Begin VB.CommandButton Command1 
         Caption         =   "4"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   4
         Left            =   120
         MaskColor       =   &H00FF0000&
         TabIndex        =   7
         Top             =   1920
         Width           =   495
      End
      Begin VB.CommandButton Command1 
         Caption         =   "5"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   5
         Left            =   720
         TabIndex        =   6
         Top             =   1920
         Width           =   495
      End
      Begin VB.CommandButton Command1 
         BackColor       =   &H00FF0000&
         Caption         =   "6"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   6
         Left            =   1320
         MaskColor       =   &H00FF0000&
         TabIndex        =   5
         Top             =   1920
         Width           =   495
      End
      Begin VB.CommandButton Command1 
         BackColor       =   &H00FF0000&
         Caption         =   "7"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   7
         Left            =   120
         TabIndex        =   4
         Top             =   1320
         Width           =   495
      End
      Begin VB.CommandButton Command1 
         Caption         =   "8"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   8
         Left            =   720
         TabIndex        =   3
         Top             =   1320
         Width           =   495
      End
      Begin VB.CommandButton Command1 
         BackColor       =   &H00000000&
         Caption         =   "9"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   12
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   9
         Left            =   1320
         MaskColor       =   &H00000000&
         TabIndex        =   2
         Top             =   1320
         Width           =   495
      End
      Begin VB.Label Label1 
         Alignment       =   1  'Right Justify
         Height          =   255
         Left            =   120
         TabIndex        =   21
         Top             =   720
         Width           =   2295
      End
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim x#, y#, s$
Private Sub Command1_Click(Index As Integer)    '数字输入
If InStr(Label1, "=") Then
  Label1.Caption = ""
End If
If Form1.Tag = "T" Then
    Text1.Text = ""
End If
    a = Text1.Text
    Text1.Text = a & Command1(Index).Caption
    y = Text1.Text
    Form1.Tag = ""
End Sub
Private Sub Command2_Click(Index As Integer)       '计算符号控制
If InStr(Label1, "=") Then
Label1.Caption = ""
End If
x = Text1.Text
Text1.Text = ""
Label1.Caption = Label1.Caption & x & Command2(Index).Caption
s = Command2(Index).Index
End Sub
Private Sub Command3_Click()
Select Case s
Case 0
Text1.Text = x + y
Case 1
Text1.Text = x - y
Case 2
Text1.Text = x * y
Case 3
    If y <> 0 Then
    Text1.Text = x / y
    Else
    MsgBox ("除数不能为零")
    End If
Case 4
Text1.Text = x ^ y
End Select
Label1.Caption = Label1.Caption & y & "=" & Text1.Text
Form1.Tag = "T"
End Sub
Private Sub Command4_Click()            '正,负号
   Text1.Text = 0 - Val(Text1.Text)
End Sub
Private Sub Command7_Click()
If InStr(Text1.Text, ".") Then         '如果已经有了“.”则跳过
   Beep
Else
   Text1.Text = Text1.Text & "."
End If
End Sub
Private Sub Command8_Click()            'AC事件
Text1.Text = ""
Label1.Caption = ""
End Sub
Private Sub Command6_Click()            'OFF事件
End
End Sub

⌨️ 快捷键说明

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