zgl263885058 zgl263885058
关注数: 4 粉丝数: 34 发帖数: 595 关注贴吧数: 10
vb 编写简易计算器,1.1版来啦,谢谢大家的指正,还望继续~ 修改了部分缺陷,改变了数据类型,添加了计算数据的预判及提示。 下载地址:http://tieba.baidu.com/mo/q/checkurl?url=http%3A%2F%2F115.com%2Ffile%2Fe6axd7lh%23&urlrefer=1350a8c6243f00132d4b78daa417ea24 简易计算器1.1.rar 本软件纯属学习交流之用,版权所有,盗版不究。 "承蒙各位网友指点,此次对代码中的部分不足做出了修改,比如数据输入合理性判断以及数据类型的修改,界面微调,不过还有bug没有办法修改,比如tan180无法进行正确计算,还请各位高手雅正,不胜感激!"Dim sum As Double Dim k As String Dim pi As Double Dim c As Double Dim d As Double Dim n As Double Dim x As Double Function ln(x) ln = Log(x) / Log(10) End Function Function Logn(x) Logn = Log(x) / Log(n) End Function Private Sub check_Click() Shell "C:\WINDOWS\explorer.exe http://tieba.baidu.com/mo/q/checkurl?url=http%3A%2F%2Fuser.qzone.qq.com%2F263885058%2Fblog%2F1322900561&urlrefer=a34806b396b99a9e93b29157c03bd775" End Sub Private Sub Command1_Click(Index As Integer) Select Case Index Case 1 Text1.Text = Text1.Text & 1 Case 2 Text1.Text = Text1.Text & 2 Case 3 Text1.Text = Text1.Text & 3 Case 4 Text1.Text = Text1.Text & 4 Case 5 Text1.Text = Text1.Text & 5 Case 6 Text1.Text = Text1.Text & 6 Case 7 Text1.Text = Text1.Text & 7 Case 8 Text1.Text = Text1.Text & 8 Case 9 Text1.Text = Text1.Text & 9 Case 0 Text1.Text = Text1.Text & 0 Case 10 Text1.Text = Text1.Text & "." End Select End Sub Private Sub Command2_Click(Index As Integer) If Text1.Text = "" Then MsgBox "请先输入第一个数字后再点击符号" Else Select Case Index Case 0 sum = Text1.Text Text1.Text = "" k = "+" Case 1 sum = Text1.Text Text1.Text = "" k = "-" Case 2 sum = Text1.Text Text1.Text = "" k = "*" Case 3 sum = Text1.Text Text1.Text = "" k = "/" End Select End If End Sub Private Sub Command3_Click() If Text1.Text = "" Then MsgBox "您未输入任何需要计算内容,请先输入需要计算内容" Text1.Text = "" Text2.Text = "" Label2.Caption = "" Label3.Caption = "" Else Dim a As Double a = Text1.Text If k = "+" Then sum = sum + a Text2.Text = sum ElseIf k = "-" Then sum = sum - a Text2.Text = sum ElseIf k = "*" Then sum = sum * a Text2.Text = sum ElseIf k = "/" Then If Text1.Text = 0 Then '判断除数是否为0,若为零弹出信息框并清空输入数据,要求重新输入 MsgBox "除数不能为零!请重新输入" Text1.Text = "" Text2.Text = "" Label2.Caption = "" Label3.Caption = "" a = 0 b = 0 k = "" Else sum = sum / a Text2.Text = sum End If ElseIf k = "sin" Then '等号的三角计算 sum = Sin(a * pi / 180) Text2.Text = sum ElseIf k = "cos" Then sum = Cos(a * pi / 180) Text2.Text = sum ElseIf k = "tan" Then Dim m As Integer Dim n As Integer m = a Mod 180 - 90
1 下一页