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

📄 calculator.frm

📁 abc其他人不需帐号就可自 由下载此源码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   BorderStyle     =   4  'Fixed ToolWindow
   Caption         =   "  Calculator v1.1"
   ClientHeight    =   1815
   ClientLeft      =   45
   ClientTop       =   285
   ClientWidth     =   2040
   ForeColor       =   &H00000000&
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   1815
   ScaleWidth      =   2040
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton Command4 
      Caption         =   "="
      Height          =   255
      Left            =   1320
      TabIndex        =   15
      Top             =   1440
      Width           =   615
   End
   Begin VB.CommandButton Command3 
      Caption         =   "C"
      Height          =   255
      Left            =   720
      TabIndex        =   14
      Top             =   1440
      Width           =   615
   End
   Begin VB.CommandButton Command2 
      Caption         =   "-"
      Height          =   255
      Left            =   120
      TabIndex        =   13
      Top             =   1440
      Width           =   615
   End
   Begin VB.CommandButton Command12 
      Caption         =   "+"
      Height          =   255
      Left            =   1320
      TabIndex        =   12
      Top             =   1200
      Width           =   615
   End
   Begin VB.CommandButton Command11 
      Caption         =   "/"
      Height          =   255
      Left            =   720
      TabIndex        =   11
      Top             =   1200
      Width           =   615
   End
   Begin VB.CommandButton Command10 
      Caption         =   "x"
      Height          =   255
      Left            =   120
      TabIndex        =   10
      Top             =   1200
      Width           =   615
   End
   Begin VB.CommandButton Command1 
      Caption         =   "9"
      Height          =   255
      Index           =   8
      Left            =   1320
      TabIndex        =   9
      Top             =   960
      Width           =   615
   End
   Begin VB.CommandButton Command1 
      Caption         =   "8"
      Height          =   255
      Index           =   7
      Left            =   720
      TabIndex        =   8
      Top             =   960
      Width           =   615
   End
   Begin VB.CommandButton Command1 
      Caption         =   "7"
      Height          =   255
      Index           =   6
      Left            =   120
      TabIndex        =   7
      Top             =   960
      Width           =   615
   End
   Begin VB.CommandButton Command1 
      Caption         =   "6"
      Height          =   255
      Index           =   5
      Left            =   1320
      TabIndex        =   6
      Top             =   720
      Width           =   615
   End
   Begin VB.CommandButton Command1 
      Caption         =   "5"
      Height          =   255
      Index           =   4
      Left            =   720
      TabIndex        =   5
      Top             =   720
      Width           =   615
   End
   Begin VB.CommandButton Command1 
      Caption         =   "4"
      Height          =   255
      Index           =   3
      Left            =   120
      TabIndex        =   4
      Top             =   720
      Width           =   615
   End
   Begin VB.CommandButton Command1 
      Caption         =   "3"
      Height          =   255
      Index           =   2
      Left            =   1320
      TabIndex        =   3
      Top             =   480
      Width           =   615
   End
   Begin VB.CommandButton Command1 
      Caption         =   "2"
      Height          =   255
      Index           =   1
      Left            =   720
      TabIndex        =   2
      Top             =   480
      Width           =   615
   End
   Begin VB.TextBox Text1 
      BackColor       =   &H00C0C0C0&
      Height          =   285
      Left            =   120
      Locked          =   -1  'True
      TabIndex        =   1
      Top             =   120
      Width           =   1815
   End
   Begin VB.CommandButton Command1 
      Caption         =   "1"
      Height          =   255
      Index           =   0
      Left            =   120
      TabIndex        =   0
      Top             =   480
      Width           =   615
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'
'
''Title: Basic Calculator Example
'
''By: Jason Hensley
'
''Contact: vbcodesource@gmail.com
'
''Website: http://www.vbcodesource.com|.org and http://www.vbforfree.com
'
''Description: A simple example of creating a basic calculator.
'
'Updated Copyright: 2007, December 14th
'
''Update v1.1: Made it to where the text would clear before adding a new number after a calculation has taken
'place. Example: If you click 1 + 1 and then the = button, it will display 2. Before this update if you
'pressed another number it would add to the number that was calculated. But now it will clear the previous
'calculation and then add the pressed number.
'
'Other: For some reason I didn't add a 0 button. I guess I didn't do it because the layout of the
'form would need to be redone. Anyways this is only a example, so a newly made calculator can add
'its own 0 button. :)
'
Dim mem As Long
Dim mem2 As Long
Dim math As String
'
'Will be used to determine whether to start a fresh calculation or not.
Dim calculated As Boolean
'
Private Sub Command1_Click(Index As Integer)

Dim a As Integer
'
'Check first if this will be a new calculation.
If calculated Then

Text1.Text = ""

a = Index + 1
Text1.SelText = a

calculated = False

Else

a = Index + 1
Text1.SelText = a%

End If

End Sub

Private Sub Command10_Click()
If Text1.Text = "" Then Exit Sub
mem& = Val(Text1.Text)
Text1.Text = ""
math$ = "*"
End Sub

Private Sub Command11_Click()
If Text1.Text = "" Then Exit Sub
mem& = Val(Text1.Text)
Text1.Text = ""
math$ = "/"
End Sub

Private Sub Command12_Click()
If Text1.Text = "" Then Exit Sub
mem& = Val(Text1.Text)
math$ = "+"
Text1.Text = ""
End Sub

Private Sub Command2_Click()
If Text1.Text = "" Then Exit Sub
mem& = Val(Text1.Text)
Text1.Text = ""
math$ = "-"
End Sub

Private Sub Command3_Click()
Text1.Text = ""
mem& = "0"
mem2& = "0"
math$ = ""
End Sub

Private Sub Command4_Click()
If Text1 = "" Then Exit Sub
mem2& = Val(Text1.Text)
Select Case math$
Case "-"
Text1.Text = Val(mem&) - Val(mem2&)
Case "+"
Text1.Text = Val(mem&) + Val(mem2&)
Case "*"
Text1.Text = Val(mem&) * Val(mem2&)
Case "/"
Text1.Text = Val(mem&) / Val(mem2&)
End Select
math$ = ""
calculated = True

End Sub

⌨️ 快捷键说明

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