VB求三角函数

来源:百度知道 编辑:UC知道 时间:2024/07/08 20:27:15
我有一个问题,关于求三角函数,需要用户输入角度 弧度,然后选择SIN COS TAN,用LABEL显示界面是这样的

♂Amour♂ 12:47:50
带码
Dim a1 As Integer

Private Sub Command1_Click()
a1 = Val(Text1.Text)
If Combo1.Text = "求Sin" And Combo2.Text = "弧度" Then
Label1.Caption = Sin(a1 * 3.14 / 180)
If Combo1.Text = "求Cos" And Combo2.Text = "弧度" Then
Label1.Caption = Cos(a1 * 3.14 / 180)
If Combo1.Text = "求Tan" And Combo2.Text = "弧度" Then
Label1.Caption = Tan(a1 * 3.14 / 180)
If Combo1.Text = "求Sin" And Combo2.Text = "角度" Then
Label1.Caption = Sin(a1)
If Combo1.Text = "求Cos" And Combo2.Text = "角度" Then
Label1.Caption = Cos(a1)
If Combo1.Text = "求Tan" And Combo2.Text = "角度" Then
Label1.Caption = Tan(a1)
End If
End If
End If
End If
End If
End If

End Sub

Private Sub Form_Load()
Combo

If Combo1.Text = "求Sin" And Combo2.Text = "弧度" Then
Label1.Caption = Sin(a1 * 3.14 / 180)
If Combo1.Text = "求Cos" And Combo2.Text = "弧度" Then
Label1.Caption = Cos(a1 * 3.14 / 180)
If Combo1.Text = "求Tan" And Combo2.Text = "弧度" Then
Label1.Caption = Tan(a1 * 3.14 / 180)
If Combo1.Text = "求Sin" And Combo2.Text = "角度" Then
Label1.Caption = Sin(a1)
If Combo1.Text = "求Cos" And Combo2.Text = "角度" Then
Label1.Caption = Cos(a1)
If Combo1.Text = "求Tan" And Combo2.Text = "角度" Then
Label1.Caption = Tan(a1)
End If
End If
End If
End If
End If
End If
逻辑不对,改成下面这样
If Combo1.Text = "求Sin" And Combo2.Text = "弧度" Then
Label1.Caption = Sin(a1 * 3.14 / 180)
End If
If Combo1.Text = "求Cos" And Combo2.Text = "弧度" Then