永发信息网

用vb制作计算器。

答案:3  悬赏:70  手机版
解决时间 2021-07-26 14:34
要求能够实现加减乘除、正弦余弦正切余切、乘方等基本操作。 最好带截图 详细能够看懂 谢谢,急!!!!!
最佳答案
我这里有,要的话加我,不明白教你
全部回答
可以吗
Private Sub CmdExp_Click() Dim Ang As Double Dim Res As Double Ang = Val(txtDisplay.Text) Res = Exp(Ang) txtDisplay.Text = Str(Res) End Sub Private Sub CmdHACos_Click() Dim St As String Dim Ang As Double Dim Res As Double St = txtDisplay.Text Ang = Val(St) if Ang = 0 Then MsgBox "所输入的数据不是一个有效值,请重新输入。", 64, "信息提示" ElseIf (Ang + Sqr(Ang * Ang - 1)) <= 0 Or (Ang * Ang - 1) < 0 Then MsgBox "所输入的数据还不是一个有效值,请重新输入。", 64, "信息提示" Else Res = Log(Ang + Sqr(Ang * Ang - 1)) txtDisplay.Text = Str$(Res) End If End Sub Private Sub CmdHACsc_Click() Dim St As String Dim Ang As Double Dim Res As Double St = txtDisplay.Text Ang = Val(St) If Ang = 0 Then MsgBox "所输入的数据不是一个有效值,请重新输入。", 64, "信息提示" ElseIf ((Sgn(Ang) * Sqr(Ang * Ang + 1) + 1) / Ang) <= 0 Or Ang = 0 Then MsgBox "所输入的数据不是一个有效值,请重新输入。", 64, "信息提示" Else Res = Log((Sgn(Ang) * Sqr(Ang * Ang + 1) + 1) / Ang) txtDisplay.Text = Str$(Res) End If End Sub Private Sub CmdHACTan_Click() Dim St As String Dim Ang As Double Dim Res As Double St = txtDisplay.Text Ang = Val(St) If (Ang + 1) * (Ang - 1) <= 0 Then MsgBox "所输入的数据不是一个有效值,请重新输入。", 64, "信息提示" Else Res = Log((Ang + 1) * (Ang - 1)) / 2 txtDisplay.Text = Str$(Res) End If End Sub Private Sub CmdHASec_Click() Dim St As String Dim Ang As Double Dim Res As Double St = txtDisplay.Text Ang = Val(St) if (-Ang * Ang + 1) < 0 Or Ang = 0 Then MsgBox "所输入的数据不是一个有效值,请重新输入。", 64, "信息提示" Else Res = Log((Sqr(-Ang * Ang + 1) + 1) / Ang) txtDisplay.Text = Str$(Res) End If End Sub Private Sub CmdHASin_Click() Dim St As String Dim Ang As Double Dim Res As Double St = txtDisplay.Text Ang = Val(St) If (Ang + Sqr(Ang * Ang + 1)) <= 0 Then MsgBox "所输入的数据不是一个有效值,请重新输入。", 64, "信息提示" Else Res = Log(Ang + Sqr(Ang * Ang + 1)) txtDisplay.Text = Str$(Res) End If End Sub Private Sub CmdHATan_Click() Dim St As String Dim Ang As Double Dim Res As Double St = txtDisplay.Text Ang = Val(St) If Ang = 1 Or Ang = -1 Or ((Ang + 1) * (Ang - 1)) < 0 Then MsgBox "所输入的数据不是一个有效值,请重新输入。", 64, "信息提示" Else Res = Log((Ang + 1) * (Ang - 1)) / 2 txtDisplay.Text = Str$(Res) End If End Sub Private Sub CmdHCos_Click() Dim St As String Dim Ang As Double Dim Res As Double St = txtDisplay.Text Ang = Val(St) Res = (Exp(Ang) + Exp(-Ang)) / 2 txtDisplay.Text = Str$(Res) End Sub Private Sub CmdHCsc_Click() Dim St As String Dim Ang As Double Dim Res As Double St = txtDisplay.Text Ang = Val(St) If (Exp(Ang) - Exp(-Ang)) = 0 Then MsgBox "所输入的数据不是一个有效值,请重新输入。", 64, "信息提示" Else Res = 2 / (Exp(Ang) - Exp(-Ang)) txtDisplay.Text = Str$(Res) End If End Sub Private Sub CmdHCTan_Click() Dim St As String Dim Ang As Double Dim Res As Double St = txtDisplay.Text Ang = Val(St) If (Exp(Ang) - Exp(-Ang)) = 0 Then MsgBox "所输入的数据不是一个有效值,请重新输入。", 64, "信息提示" Else Res = (Exp(Ang) + Exp(-Ang)) / (Exp(Ang) - Exp(-Ang)) txtDisplay.Text = Str$(Res) End If End Sub Private Sub CmdHSec_Click() Dim St As String Dim Ang As Double Dim Res As Double St = txtDisplay.Text Ang = Val(St) Res = 2 / (Exp(Ang) + Exp(-Ang)) txtDisplay.Text = Str$(Res) End Sub Private Sub cmdHSin_Click() Dim St As String Dim Ang As Double Dim Res As Double St = txtDisplay.Text Ang = Val(St) Res = (Exp(Ang) - Exp(-Ang)) / 2 txtDisplay.Text = Str$(Res) End Sub Private Sub CmdHTan_Click() Dim St As String Dim Ang As Double Dim Res As Double St = txtDisplay.Text Ang = Val(St) Res = (Exp(Ang) - Exp(-Ang)) / (Exp(Ang) + Exp(-Ang)) txtDisplay.Text = Str$(Res) End Sub Private Sub CmdLog_Click() Dim St As String Dim Ang As Double Dim Res As Double St = txtDisplay.Text Ang = Val(St) If Ang <= 0 Or Ang = 1 Then MsgBox "所输入的值不是有效值", 64, "信息提示" Else Res = Log(Ang) txtDisplay.Text = Str$(Res) End If End Sub Private Sub CmdLogN_Click() Dim St1 As String Dim St2 As String Dim Ang1 As Double Dim Ang2 As Double Dim Res As Double If txtDisplay.Text = "" Then MsgBox "请先输入真数:", 64, "信息提示" Else St1 = txtDisplay.Text Ang1 = Val(St1) MsgBox "现在请输入底数N", 64, "信息提示" txtDisplay.Text = "" St2 = InputBox("请输入底数N的值:") Ang2 = Val(St2) If Ang1 <= 0 Or Ang2 <= 0 Or Ang1 = 1 Or Ang2 = 1 Then MsgBox "所输入的值不是有效值", 64, "信息提示" Else Res = Log(Ang1) / Log(Ang2) txtDisplay.Text = Str$(Res) End If End If End Sub Private Sub CmdSec_Click() Dim Ang As Double Dim Res As Double Ang = Val(txtDisplay.Text) Res = Round(Cos(Ang * 3.14159265358979 / 180), 10) If Res = 0 Then MsgBox "你所输入的数据不在该公式的定义域内,请重新输入。", 64, "信息提示" Else Res = 1 / Res txtDisplay.Text = "" txtDisplay.Text = Str$(Res) End If End Sub Private Sub cmdSin_Click() Dim Ang As Double Dim Res As Double Ang = Val(txtDisplay.Text) Res = Round(Sin(Ang * 3.14159265358979 / 180), 10) txtDisplay.Text = "" txtDisplay.Text = Str$(Res) End Sub Private Sub CmdSqr_Click() Dim Str1 As String Dim Valu As Double Dim Res As Double Str1 = txtDisplay.Text Valu = Val(Str1) If Valu < 0 Then MsgBox "被开方数不能小于O!!!", 48, "警告" Else Res = Sqr(Valu) End If txtDisplay.Text = "" txtDisplay.Text = Str$(Res) End Sub Private Sub CmdTan_Click() Dim Ang As Double Dim Res As Double Ang = Val(txtDisplay.Text) Res = Round(Tan(Ang * 3.14159265358979 / 180), 10) txtDisplay.Text = "" txtDisplay.Text = Str$(Res) End Sub Private Sub Command1_Click() Dim St As String Dim Ang As Double Dim Res As Double St = txtDisplay.Text Ang = Val(St) Res = Atn(Ang) + 2 * Atn(1) End Sub Private Sub Timer1_Timer() StatusBar1.Panels(4).Text = "当前时间:" & Now End Sub Function ActiveButton() Text1.Text = "" Text2.Text = "" AquaButton1.Enabled = True Text1.Enabled = True End Function ' Remove the last character. Private Sub DeleteCharacter() Dim txt As String Dim min_len As Integer txt = txtDisplay.Text If Left$(txt, 1) = "-" Then min_len = 2 Else min_len = 1 End If If Len(txt) > min_len Then txtDisplay.Text = Left$(txt, Len(txt) - 1) Else txtDisplay.Text = "0" End If End Sub ' Clear the current entry, saved value, and operator. Private Sub cmdClear_Click() cmdClearEntry_Click StoredValue = 0 Operator = opNone End Sub ' Clear the current entry. Private Sub cmdClearEntry_Click() txtDisplay.Text = "" End Sub ' Add a decimal point to the display.
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
怎麽修改開始賽單德背景、
进新房有什么风俗?
踢踏舞视屏,其中有一段是一个白人和一个黑人
怎样可以防止头发产生静电?最好是快速有效实
怎样调节恋人间的这种问题?
y=x²-3x-4的开口方向 对称轴 顶点坐标
windows不能打开此文件
这是太原哪条路了知道的告下看图
2x-3分之x平方-x=A分之x-1+B分之x、其中A、B
古代的时间和现在在时间是怎样的
m4455这个流氓软件怎么清理?!
为什么我DNF不开G,老是掉出来呢?
水里面有哪些是天敌?鄂鱼有天敌吗?
电脑蓝牙连手机上网
我们的机战团队团结吗
推荐资讯
1985年1月28 和1983年7月16哪个命硬?什么时
技嘉P43-ES3G+E5300+GTS250+2GB内存玩生化5佣
NUNU 茶树精油广州哪里有得卖
保山QQ群 想找个管理 保山人 人员要好 谁愿意
将正方形ABCD沿对角线BD折叠起来,使得点A在
99聊天卡可以用手机使用吗
应该是乌尔兰吧,十几年前,有个男童星唱歌很
滁州西涧营造了怎样的氛围?传达了诗人怎样的
辞职应该怎么跟领导说,如何跟老板说辞职又不
爱国的名言警句十个字,字最少的名言
关于思念的优美句子,描写秋天思念的句子
电器中KM表示什么KM
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?