vb简易计算器源码
来源:本站原创|时间:2020-01-10|栏目:vb|点击: 次
代码如下:
复制代码 代码如下:
/**
*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
您可能感兴趣的文章
阅读排行
本栏相关
- 01-10下载文件到本地运行的vbs
- 01-10飘叶千夫指源代码,又称qq刷屏器
- 01-10SendKeys参考文档
- 01-10什么是一个高效的软件
- 01-10VBS中的正则表达式的用法大全 &l
- 01-10exe2swf 工具(Adodb.Stream版)
- 01-10VBS中SendKeys的基本应用
- 01-10用VBSCRIPT控制ONSUBMIT事件
- 01-10VBScript教程 第十一课深入VBScript
- 01-10VBScript语法速查及实例说明
随机阅读
- 01-10delphi制作wav文件的方法
- 04-02jquery与jsp,用jquery
- 01-10使用C语言求解扑克牌的顺子及n个骰子
- 08-05织梦dedecms什么时候用栏目交叉功能?
- 01-11Mac OSX 打开原生自带读写NTFS功能(图文
- 01-11ajax实现页面的局部加载
- 01-10C#中split用法实例总结
- 01-10SublimeText编译C开发环境设置
- 08-05dedecms(织梦)副栏目数量限制代码修改
- 08-05DEDE织梦data目录下的sessions文件夹有什