首页 制作计算器

制作计算器

举报
开通vip

制作计算器制作计算器 Dim cleardisplay As Boolean Dim operand1 As Double Dim operand2 As Double Dim operator As String Private Sub Command1_Click(Index As Integer) '控件数组command1(index),数字0到9 If cleardisplay Then Text1.Text = "" cleardisplay = False End If If Len(Tex...

制作计算器
制作计算器 Dim cleardisplay As Boolean Dim operand1 As Double Dim operand2 As Double Dim operator As String Private Sub Command1_Click(Index As Integer) '控件数组command1(index),数字0到9 If cleardisplay Then Text1.Text = "" cleardisplay = False End If If Len(Text1.Text) < 10 Then Text1.Text = Text1.Text + Command1(Index).Caption End If End Sub Private Sub Command11_Click() '等于号 Dim aa As Double operand2 = Val(Text1.Text) If operator = "+" Then aa = operand1 + operand2 If operator = "-" Then aa = operand1 - operand2 If operator = "*" Then aa = operand1 * operand2 If operator = "/" Then aa = operand1 / operand2 Text1.Text = aa operator = aa Text2.Text = aa End Sub Private Sub Command2_Click() '小数点 If InStr(Text1.Text, ".") Then Exit Sub Else Text1.Text = Text1.Text + "." End If End Sub Private Sub Command3_Click() '正负号 Text1.Text = -Val(Text1.Text) End Sub Private Sub Command5_Click() '清空text1,tex2里面的内容 Text1.Text = "" Text2.Text = "" End Sub Private Sub Command6_Click() '加号 operand1 = Val(Text1.Text) operator = "+" Text1.Text = "" Text2.Text = operand1 '也让他在text2里面显示 End Sub Private Sub Command7_Click() '减号 operand1 = Val(Text1.Text) operator = "-" Text1.Text = "" Text2 = operand1 '也让他在text2里面显示 End Sub Private Sub Command8_Click() '乘号 operand1 = Val(Text1.Text) operator = "*" Text1.Text = "" Text2.Text = operand1 '也让他在text2里面显示 End Sub Private Sub Command9_Click() '除号 operand1 = Val(Text1.Text) operator = "/" Text1.Text = "" Text2.Text = operand1 '也让他在text2里面显示 End Sub Private Sub Form_Load() End Sub
本文档为【制作计算器】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_624976
暂无简介~
格式:doc
大小:14KB
软件:Word
页数:0
分类:生活休闲
上传时间:2017-12-07
浏览量:16