posts - 48,  comments - 5,  trackbacks - 0

VERSION 5.00
Begin VB.Form form1
   Caption         =   "微型计算器"
   ClientHeight    =   4065
   ClientLeft      =   60
   ClientTop       =   390
   ClientWidth     =   4845
   LinkTopic       =   "Form1"
   ScaleHeight     =   4065
   ScaleWidth      =   4845
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton del
      BackColor       =   &H00FFC0C0&
      Caption         =   "del"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   2400
      Style           =   1  'Graphical
      TabIndex        =   21
      Top             =   1080
      Width           =   1215
   End
   Begin VB.CommandButton off
      BackColor       =   &H00C0C0FF&
      Caption         =   "off"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1200
      Style           =   1  'Graphical
      TabIndex        =   20
      Top             =   1080
      Width           =   1215
   End
   Begin VB.CommandButton cn
      BackColor       =   &H00C0FFC0&
      Caption         =   "cn"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   0
      MaskColor       =   &H00FF0000&
      Style           =   1  'Graphical
      TabIndex        =   19
      Top             =   1080
      UseMaskColor    =   -1  'True
      Width           =   1215
   End
   Begin VB.Timer Timer1
      Interval        =   1000
      Left            =   1800
      Top             =   600
   End
   Begin VB.CommandButton chu
      Caption         =   "/"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   3600
      TabIndex        =   16
      Top             =   2520
      Width           =   1215
   End
   Begin VB.CommandButton equal
      Caption         =   "="
      BeginProperty Font
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   3600
      TabIndex        =   15
      Top             =   3000
      Width           =   1215
   End
   Begin VB.CommandButton boil
      Caption         =   "."
      BeginProperty Font
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   2400
      TabIndex        =   14
      Top             =   3000
      Width           =   1215
   End
   Begin VB.CommandButton zero
      Caption         =   "0"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   0
      TabIndex        =   13
      Top             =   3000
      Width           =   2415
   End
   Begin VB.CommandButton sheng
      Caption         =   "*"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   3600
      TabIndex        =   12
      Top             =   2040
      Width           =   1215
   End
   Begin VB.CommandButton three
      Caption         =   "3"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   2400
      TabIndex        =   11
      Top             =   2520
      Width           =   1215
   End
   Begin VB.CommandButton two
      Caption         =   "2"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1200
      TabIndex        =   10
      Top             =   2520
      Width           =   1215
   End
   Begin VB.CommandButton one
      Caption         =   "1"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   0
      TabIndex        =   9
      Top             =   2520
      Width           =   1215
   End
   Begin VB.CommandButton jian
      Caption         =   "-"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   3600
      TabIndex        =   8
      Top             =   1560
      Width           =   1215
   End
   Begin VB.CommandButton six
      Caption         =   "6"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   2400
      TabIndex        =   7
      Top             =   2040
      Width           =   1215
   End
   Begin VB.CommandButton five
      Caption         =   "5"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1200
      TabIndex        =   6
      Top             =   2040
      Width           =   1215
   End
   Begin VB.CommandButton four
      Caption         =   "4"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   0
      TabIndex        =   5
      Top             =   2040
      Width           =   1215
   End
   Begin VB.CommandButton add
      Caption         =   "+"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   3600
      TabIndex        =   4
      Top             =   1080
      Width           =   1215
   End
   Begin VB.CommandButton nine
      Caption         =   "9"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   2400
      TabIndex        =   3
      Top             =   1560
      Width           =   1215
   End
   Begin VB.CommandButton eight
      Caption         =   "8"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1200
      TabIndex        =   2
      Top             =   1560
      Width           =   1215
   End
   Begin VB.CommandButton seven
      Caption         =   "7"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   0
      TabIndex        =   1
      Top             =   1560
      Width           =   1215
   End
   Begin VB.TextBox result
      Alignment       =   1  'Right Justify
      BeginProperty Font
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   495
      Left            =   0
      Locked          =   -1  'True
      TabIndex        =   0
      Top             =   0
      Width           =   4815
   End
   Begin VB.Label Label3
      Caption         =   "小小计算器  让您用得称心如意!^-^"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   0
      TabIndex        =   22
      Top             =   3600
      Width           =   4815
   End
   Begin VB.Label Label2
      Caption         =   " 制作者   逍湘"
      Height          =   375
      Left            =   3360
      TabIndex        =   18
      Top             =   720
      Width           =   1455
   End
   Begin VB.Label Label1
      BorderStyle     =   1  'Fixed Single
      Caption         =   "当前时间"
      BeginProperty Font
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   0
      TabIndex        =   17
      Top             =   600
      Width           =   1695
   End
End
Attribute VB_Name = "form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim a As Double
Dim b As Double
Dim c As String

Private Sub add_Click()
If (result.Text = "+") Or (result.Text = "-") Or (result.Text = "*") Or (result.Text = "/") Or (result.Text = "=") Or (result.Text = "") Then
a = 0
Else
a = CDbl(result.Text)
End If
result.Text = "+"
c = "+"
End Sub

Private Sub boil_Click()
Dim str As String
p = Split(result.Text)                    'Split:将字符串换成字符串数组
str = Join(Filter(p, ".", True), "")      'Filter : 查找字符串数组的特定字符串
                                          'Join(x[,d]) 将字符串数组合成一个字符串.
If (result.Text = "+") Or (result.Text = "*") Or (result.Text = "/") Or (result.Text = "=") Or (result.Text = "") Then
result.Text = "0."
Else
If result.Text = "-" Then
result.Text = result.Text + "0."
End If
End If

If Len(str) > 0 Then           '已输入的值中有点
result.Text = result.Text
Else
If (CDbl(result.Text) > 0) Or (CDbl(result.Text) < 0) Or (result.Text = "-0") Then
result.Text = result.Text + "."
End If
End If
End Sub

Private Sub chu_Click()
If (result.Text = "+") Or (result.Text = "-") Or (result.Text = "*") Or (result.Text = "/") Or (result.Text = "=") Or (result.Text = "") Then
a = 0
Else
a = CDbl(result.Text)
End If
result.Text = "/"
c = "/"
End Sub

Private Sub cn_Click()
result.Text = ""
a = 0
b = 0
End Sub

Private Sub del_Click()
If Len(result.Text) > 0 Then
result.Text = Left(result.Text, Len(result.Text) - 1)
End If
End Sub

Private Sub eight_Click()
If (result.Text = "+") Or (result.Text = "*") Or (result.Text = "/") Or (result.Text = "=") Or (result.Text = "") Then
result.Text = "8"
Else: result.Text = result.Text + "8"
End If
End Sub

Private Sub equal_Click()
If (result.Text = "+") Or (result.Text = "-") Or (result.Text = "*") Or (result.Text = "/") Or (result.Text = "=") Or (result.Text = "") Then
result.Text = "="
b = 0
Else
If c = "-" Then
b = -CDbl(result.Text)
Else
b = CDbl(result.Text)
End If
End If

If c = "+" Then
If ((a + b) < -1.7E+308) Or ((a + b) > 1.7E+308) Then
MsgBox ("对不起,您所求的结果超出了本计算器范围!请您选用更精密的计算器吧!")
Else
result.Text = CStr(a + b)
End If
End If

If c = "-" Then
If ((a - b) < -1.7E+308) Or ((a - b) > 1.7E+308) Then
MsgBox ("对不起,您所求的结果超出了本计算器范围!请您选用更精密的计算器吧!")
Else
result.Text = CStr(a - b)
End If
End If

If c = "*" Then
If ((a * b) < -1.7E+308) Or ((a * b) > 1.7E+308) Then
MsgBox ("对不起,您所求的结果超出了本计算器范围!请您选用更精密的计算器吧!")
Else
result.Text = CStr(a * b)
End If
End If

If c = "/" Then
If b = 0 Then
MsgBox ("对不起,除数不能为 0 !!")
Else
If ((a / b) < -1.7E+308) Or ((a / b) > 1.7E+308) Then
MsgBox ("对不起,您所求的结果超出了本计算器范围!请您选用更精密的计算器吧!")
Else
result.Text = CStr(a / b)
End If
End If
End If
End Sub

Private Sub five_Click()
If (result.Text = "+") Or (result.Text = "*") Or (result.Text = "/") Or (result.Text = "=") Or (result.Text = "") Then
result.Text = "5"
Else: result.Text = result.Text + "5"
End If
End Sub

Private Sub four_Click()
If (result.Text = "+") Or (result.Text = "*") Or (result.Text = "/") Or (result.Text = "=") Or (result.Text = "") Then
result.Text = "4"
Else: result.Text = result.Text + "4"
End If
End Sub

Private Sub jian_Click()
If (result.Text = "+") Or (result.Text = "-") Or (result.Text = "*") Or (result.Text = "/") Or (result.Text = "=") Or (result.Text = "") Then
a = 0
Else
a = CDbl(result.Text)
End If
result.Text = "-"
c = "-"
End Sub


Private Sub nine_Click()
If (result.Text = "+") Or (result.Text = "*") Or (result.Text = "/") Or (result.Text = "=") Or (result.Text = "") Then
result.Text = "9"
Else: result.Text = result.Text + "9"
End If
End Sub

Private Sub off_Click()
End
End Sub

 

Private Sub one_Click()
If (result.Text = "+") Or (result.Text = "*") Or (result.Text = "/") Or (result.Text = "=") Or (result.Text = "") Then
result.Text = "1"
Else: result.Text = result.Text + "1"
End If
End Sub

Private Sub seven_Click()
If (result.Text = "+") Or (result.Text = "*") Or (result.Text = "/") Or (result.Text = "=") Or (result.Text = "") Then
result.Text = "7"
Else: result.Text = result.Text + "7"
End If
End Sub

Private Sub sheng_Click()
If (result.Text = "+") Or (result.Text = "-") Or (result.Text = "*") Or (result.Text = "/") Or (result.Text = "=") Or (result.Text = "") Then
a = 0
Else
a = CDbl(result.Text)
End If
result.Text = "*"
c = "*"
End Sub

Private Sub six_Click()
If (result.Text = "+") Or (result.Text = "*") Or (result.Text = "/") Or (result.Text = "=") Or (result.Text = "") Then
result.Text = "6"
Else: result.Text = result.Text + "6"
End If
End Sub

Private Sub three_Click()
If (result.Text = "+") Or (result.Text = "*") Or (result.Text = "/") Or (result.Text = "=") Or (result.Text = "") Then
result.Text = "3"
Else: result.Text = result.Text + "3"
End If
End Sub

Private Sub Timer1_Timer()
Label1.Caption = Time

End Sub

Private Sub two_Click()
If (result.Text = "+") Or (result.Text = "*") Or (result.Text = "/") Or (result.Text = "=") Or (result.Text = "") Then
result.Text = "2"
Else: result.Text = result.Text + "2"
End If
End Sub

Private Sub zero_Click()
If (result.Text = "+") Or (result.Text = "*") Or (result.Text = "/") Or (result.Text = "=") Or (result.Text = "") Then
result.Text = "0."
Else
If result.Text = "-" Then
result.Text = result.Text + "0."
Else: result.Text = result.Text + "0"
End If
End If
End Sub

posted on 2008-01-05 10:14 逍湘 阅读(713) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
博客园   IT新闻   Chat2DB   C++博客   博问  
 

留言簿(2)

随笔档案(49)

文章档案(17)

最新随笔

积分与排名

  • 积分 - 25835
  • 排名 - 1500

最新评论

阅读排行榜