|

楼主 |
发表于 2021-2-10 08:10
|
显示全部楼层
修改调试后的程序代码如下,供朋友参考:
Option Explicit
Const pi = "3.141592653589793238462"
Dim x As Double, y As Double
Private Sub Form_Load()
Option1.Value = True
End Sub
Private Sub Command1_Click()
Dim x As Double, y As Double
Dim asin As Double
x = Val(Text1.Text)
If Option1 = True Then
x = Val(x * pi / 180)
Else
x = x
End If
y = Sin(x)
Text2 = y
End Sub
Function Sec(x) As Double '正割
Sec = 1 / Cos(x)
End Function
Function Csc(x) As Double '余割
Csc = 1 / Sin(x)
End Function
Function Cot(x) As Double '余切
Cot = 1 / Tan(x)
End Function
Function ArcSin(x) As Double '反正弦
ArcSin = Atn(x / Sqr(-x * x + 1))
End Function
Function ArcCos(x) As Double '反余弦
ArcCos = Atn(-x / Sqr(-x * x + 1)) + 2 * Atn(1)
End Function
Function ArcSec(x) As Double '反正割
ArcSec = Atn(x / Sqr(x * x - 1)) + Sgn((x) - 1) * (2 * Atn(1))
End Function
Function ArcCsc(x) As Double '反余割
ArcCsc = Atn(x / Sqr(x * x - 1)) + (Sgn(x) - 1) * (2 * Atn(1))
End Function
Function ArcCot(x) As Double '反余切
ArcCot = ArcSec(x) / ArcCsc(x)
End Function
Private Sub Command10_Click()
Text1 = ""
Text2 = ""
End Sub
Private Sub Command2_Click()
x = Text1
If x = 1 Then
y = pi / 2
ElseIf x = -1 Then
y = 0 - pi / 2
Else
y = ArcSin(x)
End If
If Option1 = True Then
y = Val(y * 180 / pi)
Else
y = y
End If
Text2 = y
End Sub
Private Sub Command3_Click()
Dim x, y
x = Text1
If Option1 = True Then
x = Val(x * pi / 180)
Else
x = x
End If
y = Cos(x)
Text2 = y
End Sub
Private Sub Command4_Click()
x = Text1
If x = 1 Then
y = 0
ElseIf x = -1 Then
y = pi
Else
y = ArcCos(x)
End If
If Option1 = True Then
y = Val(y * 180 / pi)
Else
y = y
End If
Text2 = y
End Sub
Private Sub Command5_Click()
x = Text1
If Option1 = True Then
x = Val(x * pi / 180)
Else
x = x
End If
y = Tan(x)
Text2 = y
End Sub
Private Sub Command6_Click()
Dim x, y
x = Text1
y = Atn(x)
If Option1 = True Then
y = Val(y * 180 / pi)
Else
y = y
End If
Text2 = y
End Sub
Private Sub Command7_Click()
x = Text1
If Option1 = True Then
x = Val(x * pi / 180)
Else
x = x
End If
y = 1 / Tan(x)
Text2 = y
End Sub
Private Sub Command8_Click()
Dim x, y
x = Text1
y = Atn(1 / x)
If Option1 = True Then
y = Val(y * 180 / pi)
Else
y = y
End If
Text2 = y
End Sub
Private Sub Command9_Click()
End
End Sub
Private Sub Option1_Click()
Option1 = True
End Sub
Private Sub Option2_Click()
Option2 = True
End Sub
|
|