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

📄 计算器.frm

📁 VB编的一个计算器程序
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Index           =   2
      Left            =   1320
      TabIndex        =   4
      Top             =   3360
      Width           =   735
   End
   Begin VB.CommandButton Command1 
      Caption         =   "1"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Index           =   1
      Left            =   360
      TabIndex        =   3
      Top             =   3360
      Width           =   735
   End
   Begin VB.CommandButton Command1 
      Caption         =   "0"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Index           =   0
      Left            =   2280
      TabIndex        =   2
      Top             =   6240
      Width           =   735
   End
   Begin VB.TextBox Text2 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00FFC0C0&
      BeginProperty Font 
         Name            =   "Microsoft Sans Serif"
         Size            =   14.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00000000&
      Height          =   480
      Left            =   1200
      MultiLine       =   -1  'True
      TabIndex        =   1
      Text            =   "计算器.frx":0000
      Top             =   1680
      Width           =   3135
   End
   Begin VB.TextBox Text1 
      Alignment       =   1  'Right Justify
      BackColor       =   &H00C0C0FF&
      BeginProperty Font 
         Name            =   "Trebuchet MS"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1680
      TabIndex        =   0
      Text            =   "00-00-00"
      Top             =   960
      Width           =   1335
   End
   Begin VB.Label Label1 
      BackColor       =   &H00C0C0FF&
      Caption         =   "简单计算器"
      BeginProperty Font 
         Name            =   "隶书"
         Size            =   26.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF00FF&
      Height          =   615
      Left            =   720
      TabIndex        =   18
      Top             =   240
      Width           =   2775
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public m As Double
Public JS_char As String
Public BJ As Boolean

Private Sub Command1_Click(Index As Integer)
 If BJ = True Then Text2.Text = 0
 Select Case Index
  Case 0
   If Text2.Text = 0 Then Text2.Text = 0 Else Text2.Text = Text2.Text & 0
   BJ = False
   
  Case 1
    If Text2.Text = 0 & Chr(46) Then
       Text2.Text = 0 & Chr(46) & 1
    ElseIf Text2.Text = 0 Then
       Text2.Text = 1
    Else
       Text2.Text = Text2.Text & 1
    End If
    BJ = False
    
  Case 2
    If Text2.Text = 0 & Chr(46) Then
       Text2.Text = 0 & Chr(46) & 2
    ElseIf Text2.Text = 0 Then
       Text2.Text = 2
    Else
       Text2.Text = Text2.Text & 2
    End If
    BJ = False
    
  Case 3
    If Text2.Text = 0 & Chr(46) Then
       Text2.Text = 0 & Chr(46) & 3
    ElseIf Text2.Text = 0 Then
       Text2.Text = 3
    Else
       Text2.Text = Text2.Text & 3
    End If
    BJ = False
    
  Case 4
    If Text2.Text = 0 & Chr(46) Then
       Text2.Text = 0 & Chr(46) & 4
    ElseIf Text2.Text = 0 Then
       Text2.Text = 4
    Else
       Text2.Text = Text2.Text & 4
    End If
    BJ = False
    
  Case 5
    If Text2.Text = 0 & Chr(46) Then
       Text2.Text = 0 & Chr(46) & 5
    ElseIf Text2.Text = 0 Then
       Text2.Text = 5
    Else
       Text2.Text = Text2.Text & 5
    End If
    BJ = False
    
  Case 6
    If Text2.Text = 0 & Chr(46) Then
       Text2.Text = 0 & Chr(46) & 6
    ElseIf Text2.Text = 0 Then
       Text2.Text = 6
    Else
       Text2.Text = Text2.Text & 6
    End If
    BJ = False
    
  Case 7
    If Text2.Text = 0 & Chr(46) Then
       Text2.Text = 0 & Chr(46) & 7
    ElseIf Text2.Text = 0 Then
       Text2.Text = 7
    Else
       Text2.Text = Text2.Text & 7
    End If
    BJ = False
    
  Case 8
    If Text2.Text = 0 & Chr(46) Then
       Text2.Text = 0 & Chr(46) & 8
    ElseIf Text2.Text = 0 Then
       Text2.Text = 8
    Else
       Text2.Text = Text2.Text & 8
    End If
    BJ = False
    
  Case 9
    If Text2.Text = 0 & Chr(46) Then
       Text2.Text = 0 & Chr(46) & 9
    ElseIf Text2.Text = 0 Then
       Text2.Text = 9
    Else
       Text2.Text = Text2.Text & 9
    End If
    BJ = False
    
  Case 10
    If Text2.Text = 0 Then Text2.Text = 0 & Chr(46) Else Text2.Text = Text2.Text & Chr(46)
    Command1(10).Enabled = False
 End Select
End Sub

Private Sub Command10_Click()
 m = Val(Text2.Text)
 Text2.Text = 0
 Command1(10).Enabled = True
 JS_char = "%"
End Sub

Private Sub Command11_Click()
 Select Case JS_char
  Case "+"
    Text2.Text = m + Val(Text2.Text)
    Command1(10).Enabled = True
  Case "-"
    Text2.Text = m - Val(Text2.Text)
    Command1(10).Enabled = True
  Case "*"
    Text2.Text = m * Val(Text2.Text)
    Command1(10).Enabled = True
  Case "/"
    If Text2.Text = 0 Then
       Text2.Text = "小学没毕业的滚!"
    Else
       Text2.Text = m / Val(Text2.Text)
    End If
    Command1(10).Enabled = True
  Case "%"
    Text2.Text = m Mod Val(Text2.Text)
    Command1(10).Enabled = True
  Case "^"
    Text2.Text = m ^ Val(Text2.Text)
    Command1(10).Enabled = True
  Case "log"
    If m = 1 Then
       Text2.Text = "初中没毕业的滚!"
    Else
       Text2.Text = Log(Val(Text2.Text)) / Log(m)
    End If
    Command1(10).Enabled = True
 End Select
 JS_char = ""
 BJ = True
 If Val(Text2.Text) < 1 And Val(Text2.Text) > -1 And Val(Text2.Text) <> 0 Then
    Text2.Text = 0 & Text2.Text
 End If
End Sub

Private Sub Command12_Click()
 Text2.BackColor = &HFFC0C0
 Text2.Text = 0
  Dim i As Integer
  Dim j As Integer
  For i = 0 To 10
    Command1(i).Enabled = True
  Next i
  Command2.Enabled = True
  Command3.Enabled = True
  Command4.Enabled = True
  Command5.Enabled = True
  Command6.Enabled = True
  Command7.Enabled = True
  Command8.Enabled = True
  Command9.Enabled = True
  Command10.Enabled = True
  Command11.Enabled = True
  Command13.Enabled = True
  Command12.Enabled = False
  Command13.BackColor = &H808080
  Command12.BackColor = &H80FF80
  
End Sub

Private Sub Command13_Click()
  Text2.BackColor = &H404040
  Text2.Text = ""
  Dim i As Integer
  Dim j As Integer
  For i = 0 To 10
    Command1(i).Enabled = False
  Next i
  Command2.Enabled = False
  Command3.Enabled = False
  Command4.Enabled = False
  Command5.Enabled = False
  Command6.Enabled = False
  Command7.Enabled = False
  Command8.Enabled = False
  Command9.Enabled = False
  Command10.Enabled = False
  Command11.Enabled = False
  Command13.Enabled = False
  Command12.Enabled = True
  Command13.BackColor = &H80FF80
  Command12.BackColor = &H808080
End Sub

Private Sub Command2_Click()
 m = Val(Text2.Text)
 BJ = True
 Command1(10).Enabled = True
 JS_char = "+"
End Sub

Private Sub Command3_Click()
 m = Val(Text2.Text)
 BJ = True
 Command1(10).Enabled = True
 JS_char = "-"
End Sub

Private Sub Command4_Click()
 m = Val(Text2.Text)
 BJ = True
 Command1(10).Enabled = True
 JS_char = "*"
End Sub

Private Sub Command5_Click()
 m = Val(Text2.Text)
 BJ = True
 Command1(10).Enabled = True
 JS_char = "/"
End Sub

Private Sub Command6_Click()
 m = Val(Text2.Text)
 BJ = True
 Command1(10).Enabled = True
 JS_char = "^"
End Sub

Private Sub Command7_Click()
 m = Val(Text2.Text)
 BJ = True
 Command1(10).Enabled = True
 JS_char = "log"
End Sub

Private Sub Command8_Click()
If Len(Text2.Text) > 1 Then
   Text2.Text = Mid(Text2.Text, 1, Len(Text2.Text) - 1)
Else
   Text2.Text = 0
End If
If InStr(Text2.Text, Chr(46)) = 0 Then
   Command1(10).Enabled = True
End If
End Sub

Private Sub Command9_Click()
 m = 0
 Text2.Text = 0
 Command1(10).Enabled = True
End Sub

Private Sub Form_Load()
 Text2.BackColor = &H404040
 Text2.Text = ""
  Dim i As Integer
  Dim j As Integer
  For i = 0 To 10
    Command1(i).Enabled = False
  Next i
  Command2.Enabled = False
  Command3.Enabled = False
  Command4.Enabled = False
  Command5.Enabled = False
  Command6.Enabled = False
  Command7.Enabled = False
  Command8.Enabled = False
  Command9.Enabled = False
  Command10.Enabled = False
  Command11.Enabled = False
  Command13.Enabled = False
  Command12.Enabled = True
End Sub

Private Sub Timer1_Timer()
  Text3.Text = Time
  Text1.Text = Date
End Sub

⌨️ 快捷键说明

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