中易网

哪位高手能帮我编写一个VB计算器程序?

答案:1  悬赏:50  
解决时间 2021-04-27 16:59
各路高手,小弟现在需要一份VB作业,是个计算器程序,用VB6.0版本,界面包括0~9十个数字键,+-*\=五个运算键,还有小数点,外加一个清除键,希望高手编程后把代码连同界面截图一起发给我,谢谢了~可以的话我给你我的邮箱,谢谢~
最佳答案
给LZ下面这个计算器程序吧
=检举Public a, b As Double
Public CalKey As String
Private Sub Form_Load()
Text1.Text = 0
End Sub
Private Sub Command1_Click(Index As Integer)
Text1.Text = Trim(Text1.Text)
If Text1.Text = "0" Then Text1.Text = ""
If Index <= 9 Then   
Text1.Text = Text1.Text & Format(Index)
ElseIf Index = 10 Then   
Text1.Text = 
Text1.Text & "."
ElseIf Index = 11 Then   
If Len(Text1.Text) >= 1 Then 
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
ElseIf Index = 12 Then   
Text1.Text = 0
ElseIf Index = 13 Then   
Text1.Text = -Val(Text1.Text)
End If
End Sub
Private Sub Command3_Click(Index As Integer)
a = Val(Text1.Text)
Select Case Index   
Case 0
CalKey = "+"   
Case 1
CalKey = "-"   
Case 2
CalKey = "*"   
Case 3
CalKey = "/"   
Case 4
CalKey = "%"
Call Command4_Click   
Case 5
CalKey = "sqr"
Call Command4_Click   
Case 6
CalKey = "sin"
Call Command4_Click   
Case 7
CalKey = "cos"
Call Command4_Click
End Select
If Index <= 3 Then   
Text1.Text = ""
End If
End Sub
rivate Sub Command4_Click()
b = Val(Text1.Text)
Select Case CalKey
Case "+"
Text1.Text = a + b
Case "-"
Text1.Text = a - b
Case "*"
Text1.Text = a * b
Case "/"
If b <> 0 Then
Text1.Text = a / b
Else
Text1.Text = ""
MsgBox "除数不能为0"
End If
Case "%"
Text1.Text = a / 100#
Case "sqr"
If a >= 0 Then   
Text1.Text = Sqr(a)
Else
Text1.Text = ""
MsgBox "二次方根,输入数不能小于0"
End If
Case "sin"
If a >= -1 And a <= 1 Then   
Text1.Text = Sin(a)
Else
Text1.Text = ""
MsgBox "正弦函数,输入数应介于[-1, 1]之间"
End If
Case "cos"
If a >= -1 And a <= 1 Then   
Text1.Text = Cos(a)
Else
Text1.Text = ""
MsgBox "余弦函数,输入数应介于[-1, 1]之间"
End If
End Select
If Left(Text1.Text, 1) = "." Then 
Text1.Text = "0" & Text1.Text
End Sub
Private Sub Command5_Click()
Unload Me
End Sub
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
长春现在正在施工的工地具体地址?
武候祠作文600字
台服好友招募服务器锁定了
lenovoG455为什么视频后不能语音
DNF广东8区收把50黑光多少钱,小弟在收
dnf强化11武器技巧
帮忙 做2张闪图我要用QQ头像
为什么我红色警戒心灵终结3.0玩不了?还有这
取一个锅炉安装维修证需要多少钱
徐州哪里收购金项链
加工一批机器,原计划每天生产40台,30天完成,
急助,会计电算化软件新建帐套出现了不能登陆
局域网联机,有密码,求破解方法
为什么我的q宠暂停成长也登不上社区
<激情乐翻天>走进泗洪公益演出
推荐资讯
新安小额贷款有限公司怎么样
海信电视好不好
为什么问问开了还会关掉?
元旦快到了奥迪A6汽车会降价么?
当你在工作的时候你的上级总是喜欢拿住你的小
死神剧场版呼唤君之名什么时候内地才能看?
怎么样减肥???
亚纶出个人EP你们会不会买呢,为什么?
在家安装无线路由器好吗?如果是免费的话那大
“人老如灯灭”下联是什么?
从上海师范大学(桂林路100号)如何到上海工
目前跑跑卡丁车中什么车最适合跑团体道具赛?
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?