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

📄 计算器作业.frm

📁 jisuanqilaide
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "计算器"
   ClientHeight    =   5370
   ClientLeft      =   4860
   ClientTop       =   3120
   ClientWidth     =   4245
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   5370
   ScaleWidth      =   4245
   Begin VB.CommandButton Command9 
      Caption         =   "tan"
      Height          =   375
      Index           =   2
      Left            =   1680
      TabIndex        =   23
      Top             =   3360
      Width           =   855
   End
   Begin VB.CommandButton Command9 
      Caption         =   "cos"
      Height          =   375
      Index           =   1
      Left            =   2760
      TabIndex        =   22
      Top             =   3360
      Width           =   855
   End
   Begin VB.CommandButton Command9 
      Caption         =   "sin"
      Height          =   375
      Index           =   0
      Left            =   600
      TabIndex        =   21
      Top             =   3360
      Width           =   855
   End
   Begin VB.CommandButton Command8 
      Caption         =   "back"
      Height          =   375
      Left            =   2520
      TabIndex        =   16
      Top             =   2880
      Width           =   495
   End
   Begin VB.CommandButton Command7 
      Caption         =   "+\-"
      Height          =   375
      Left            =   2520
      TabIndex        =   15
      Top             =   2400
      Width           =   495
   End
   Begin VB.CommandButton Command6 
      Caption         =   "cls"
      Height          =   375
      Left            =   2520
      TabIndex        =   13
      Top             =   1440
      Width           =   495
   End
   Begin VB.CommandButton Command5 
      Caption         =   "."
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1200
      TabIndex        =   11
      Top             =   2880
      Width           =   495
   End
   Begin VB.CommandButton Command4 
      Caption         =   "sqrt"
      Height          =   375
      Left            =   2520
      TabIndex        =   14
      Top             =   1920
      Width           =   495
   End
   Begin VB.CommandButton Command3 
      Caption         =   "="
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1800
      TabIndex        =   12
      Top             =   2880
      Width           =   495
   End
   Begin VB.CommandButton Command1 
      Caption         =   "9"
      Height          =   375
      Index           =   9
      Left            =   600
      TabIndex        =   10
      Top             =   2880
      Width           =   495
   End
   Begin VB.CommandButton Command2 
      Caption         =   "*"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Index           =   3
      Left            =   3120
      TabIndex        =   20
      Top             =   2880
      Width           =   495
   End
   Begin VB.CommandButton Command2 
      Caption         =   "-"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Index           =   2
      Left            =   3120
      TabIndex        =   19
      Top             =   2400
      Width           =   495
   End
   Begin VB.CommandButton Command2 
      Caption         =   "+"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Index           =   1
      Left            =   3120
      TabIndex        =   18
      Top             =   1920
      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
      Height          =   435
      Left            =   480
      Locked          =   -1  'True
      MaxLength       =   20
      TabIndex        =   0
      TabStop         =   0   'False
      Top             =   600
      Width           =   3255
   End
   Begin VB.CommandButton Command2 
      Caption         =   "/"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Index           =   0
      Left            =   3120
      TabIndex        =   17
      Top             =   1440
      Width           =   495
   End
   Begin VB.CommandButton Command1 
      Caption         =   "8"
      Height          =   375
      Index           =   8
      Left            =   1800
      TabIndex        =   9
      Top             =   2400
      Width           =   495
   End
   Begin VB.CommandButton Command1 
      Caption         =   "7"
      Height          =   375
      Index           =   7
      Left            =   1200
      TabIndex        =   8
      Top             =   2400
      Width           =   495
   End
   Begin VB.CommandButton Command1 
      Caption         =   "6"
      Height          =   375
      Index           =   6
      Left            =   600
      TabIndex        =   7
      Top             =   2400
      Width           =   495
   End
   Begin VB.CommandButton Command1 
      Caption         =   "5"
      Height          =   375
      Index           =   5
      Left            =   1800
      TabIndex        =   6
      Top             =   1920
      Width           =   495
   End
   Begin VB.CommandButton Command1 
      Caption         =   "4"
      Height          =   375
      Index           =   4
      Left            =   1200
      TabIndex        =   5
      Top             =   1920
      Width           =   495
   End
   Begin VB.CommandButton Command1 
      Caption         =   "3"
      Height          =   375
      Index           =   3
      Left            =   600
      TabIndex        =   4
      Top             =   1920
      Width           =   495
   End
   Begin VB.CommandButton Command1 
      Caption         =   "2"
      Height          =   375
      Index           =   2
      Left            =   1800
      TabIndex        =   3
      Top             =   1440
      Width           =   495
   End
   Begin VB.CommandButton Command1 
      Caption         =   "1"
      Height          =   375
      Index           =   1
      Left            =   1200
      TabIndex        =   2
      Top             =   1440
      Width           =   495
   End
   Begin VB.CommandButton Command1 
      Caption         =   "0"
      Height          =   375
      Index           =   0
      Left            =   600
      TabIndex        =   1
      Top             =   1440
      Width           =   495
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim num1#, num2#
Dim res As Boolean
Dim op As Byte

Private Sub Command1_Click(Index As Integer)
If res = False Then
Text1 = Text1 & Index
Else
Text1 = Index
End If
res = False
End Sub

Private Sub Command2_Click(Index As Integer)
If Text1 <> "" Then

num1 = Text1
op = Index
End If
res = True
End Sub
Private Sub Command3_Click()
If Text1 <> "" Then
num2 = Text1
Select Case op
Case 0
If num2 = 0 Then
Text1 = "除数不能为零"
Else
Text1 = num1 / num2
End If
Case 1
Text1 = num1 + num2
Case 2
Text1 = num1 - num2
Case 3
Text1 = num1 * num2
End Select
res = True
End If
End Sub

Private Sub Command4_Click()
If Text1 <> "" Then
Text1 = Sqr(Text1)
End If
res = True
End Sub

Private Sub Command5_Click()
If res = True Then
Text1 = "."
ElseIf InStr(Text1, ".") = 0 Then
Text1 = Text1 & "."
End If
res = False
End Sub

Private Sub Command6_Click()
Text1 = ""
res = False
End Sub



Private Sub Command7_Click()
If Text1 <> "" Then
Select Case Sgn(Text1)
Case 1
Text1 = "-" & Text1
Case -1
Text1 = Abs(Text1)
End Select
End If
End Sub

Private Sub Command8_Click()
If Text1 <> "" Then
a = Len(Text1)
Text1 = Left(Text1, a - 1)
End If
End Sub

Private Sub Command9_Click(Index As Integer)
If Text1 <> "" Then
Select Case Index
Case 0
Text1 = Sin(Text1)
Case 1
Text1 = Cos(Text1)
Case 2
Text1 = Tan(Text1)
End Select
End If
End Sub

Private Sub Form_Load()
res = False
End Sub

⌨️ 快捷键说明

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