永发信息网

用vb制作计算器。

答案:3  悬赏:70  手机版
解决时间 2021-07-26 14:34
  • 提问者网友:皆是孤独
  • 2021-07-26 00:09
要求能够实现加减乘除、正弦余弦正切余切、乘方等基本操作。 最好带截图 详细能够看懂 谢谢,急!!!!!
最佳答案
  • 五星知识达人网友:污到你湿
  • 2021-07-26 01:09
我这里有,要的话加我,不明白教你
全部回答
  • 1楼网友:woshuo
  • 2021-07-26 03:27
可以吗
  • 2楼网友:三千妖杀
  • 2021-07-26 02:22
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.
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯