时间:2021-05-19
代码如下:
复制代码 代码如下:
/**
*Author:乌鸟heart
*Version:1.0
*/
Dim IntX As Double '全局变量,用于存储计算的数值
Dim IntOperation As Double '标记运算类型
Dim isBegin As Boolean '标记是否已经给IntX赋值
Public Sub Clear() '清空命令函数
screen.Caption = ""
End Sub
Public Sub SavaToIntX()
Select Case IntOperation
Case 1 '加法
If isBegin = False Then
IntX = Val(screen.Caption)
isBegin = True
Else
IntX = IntX + Val(screen.Caption)
End If
Case 2 '减法
If isBegin = False Then
IntX = Val(screen.Caption)
isBegin = True
Else
IntX = IntX - Val(screen.Caption)
End If
Case 3 '乘法
If isBegin = False Then
IntX = Val(screen.Caption)
isBegin = True
Else
IntX = IntX * Val(screen.Caption)
'screen.Caption = IntX
End If
Case 4 '除法
If isBegin = False Then
IntX = Val(screen.Caption)
isBegin = True
Else
IntX = IntX / Val(screen.Caption)
End If
End Select
End Sub
Private Sub Command0_Click()
screen.Caption = screen.Caption & 0
End Sub
Private Sub Command1_Click()
screen.Caption = screen.Caption & 1
End Sub
Private Sub Command2_Click()
screen.Caption = screen.Caption & 2
End Sub
Private Sub Command3_Click()
screen.Caption = screen.Caption & 3
End Sub
Private Sub Command4_Click()
screen.Caption = screen.Caption & 4
End Sub
Private Sub Command5_Click()
screen.Caption = screen.Caption & 5
End Sub
Private Sub Command6_Click()
screen.Caption = screen.Caption & 6
End Sub
Private Sub Command7_Click()
screen.Caption = screen.Caption & 7
End Sub
Private Sub Command8_Click()
screen.Caption = screen.Caption & 8
End Sub
Private Sub Command9_Click()
screen.Caption = screen.Caption & 9
End Sub
Private Sub CommandClear_Click() '清空命令
isBegin = False
IntOperation = 0
IntX = 0
screen.Caption = ""
End Sub
Private Sub CommandEqual_Click() '等号运算
If IntOperation <> 0 Then '有运算标记的情况
Call SavaToIntX
IntOperation = 0
isBegin = False
screen.Caption = IntX
End If
End Sub
Private Sub CommandMinus_Click() '减法运算
If IntOperation <> 0 Then '有运算标记的情况
Call SavaToIntX
IntOperation = 2
Call Clear
Else
IntOperation = 2
Call SavaToIntX
Call Clear
End If
End Sub
Private Sub CommandMultiple_Click() '乘法运算
If IntOperation <> 0 Then '有运算标记的情况
Call SavaToIntX
IntOperation = 3
Call Clear
Else
IntOperation = 3
Call SavaToIntX
Call Clear
End If
End Sub
Private Sub CommandPlus_Click() '加法运算
If IntOperation <> 0 Then '有运算标记的情况
Call SavaToIntX
IntOperation = 1
Call Clear
Else
IntOperation = 1
Call SavaToIntX
Call Clear
End If
End Sub
Private Sub CommandSlash_Click() '除法运算
If IntOperation <> 0 Then '有运算标记的情况
Call SavaToIntX
IntOperation = 4
Call Clear
Else
IntOperation = 4
Call SavaToIntX
Call Clear
End If
End Sub
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
本文实例讲述了Python实现的简单计算器功能。分享给大家供大家参考,具体如下:使用python编写一款简易的计算器计算器效果图首先搭建计算器的面板:计算器面板
本文实例为大家分享了js简易计算器的具体代码,供大家参考,具体内容如下代码如下简易计算器*{margin:0;padding:0;}.content{width
本文实例为大家分享了JavaScript实现简易计算器的具体代码,供大家参考,具体内容如下计算器计算结果:functioncount(){varnum1=doc
本文实例讲述了Python正则表达式实现简易计算器功能。分享给大家供大家参考,具体如下:需求:使用正则表达式完成一个简易计算器。功能:能够计算简单的表达式。如:
本文实例为大家分享了javascript实现简易计算器的具体代码,供大家参考,具体内容如下编辑了几个小时研发了一个简易好理解的计算器。不停改Bug,终于改好了。