vb画tan函数图像If Combo1.Text = "tan" ThenFor x = -15 To 15 Step
1个回答

答案补充:Cot函数这样修改即可.主要是你没有定义y的类型.至于fi*pi/180与fi有什么区别,那要根据你的fi单位而定.如果你是以角度输入的,那么应该加上*pi/180,如果本身是以弧度输入的,就直接写fi即可.

====================

Private Sub Command1_Click()

Dim x As Single, y As Single

Picture1.Scale (-15, 15)-(15, -15)

For x = -15 To 15 Step 0.001

w = 1

y = 1 / (Tan(w * x))

Picture1.PSet (x, y), RGB(0, 255, 0)

Next x

End Sub

===================

建一个Command1,Picture1,Combo1.使用的时候,请先在Combo1中选择或者输入tan,然后单击按钮.

代码如下.

=================

Const pi = 3.14159265

Private Sub Command1_Click()

Dim x As Single, y As Single, w As Single, fi As Single

If Combo1.Text = "tan" Then

w = 1

fi = 0

Picture1.Scale (-15, 15)-(15, -15)

For x = -15 To 15 Step 0.001

y = Tan(w * x + fi)

Picture1.PSet (x, y), RGB(0, 255, 0)

Next x

End If

End Su