怎么用VB画函数图像?
用VB画出函数图像,例如二次函数等。坐标轴上是要有标度的!!谢谢!!但是我还想要有X、Y轴,不只是有图像...
用VB画出函数图像,例如二次函数等。坐标轴上是要有标度的!!谢谢!!
但是我还想要有X、Y轴,不只是有图像 展开
但是我还想要有X、Y轴,不只是有图像 展开
2个回答
展开全部
1、先定义坐标系,即XY轴。
2、根据具体需要,调用内部函数,或自定义函数,绘制函数图像。
3、代码供参考:
Me.AutoRedraw = True
Me.Width = 8000: Me.Height = 6000
Me.Scale (-10, 2)-(10, -2)
Line (0, -2)-(0, 2)
Line (-20, 0)-(20, 0)
For i! = -2 To 2 Step 0.5
Line (0, i)-(0.5, i)
CurrentX = -1.8
CurrentY = i
Print i
Next i
For j! = -8 To 10 Step 2
Line (j, 0)-(j, 0.05)
CurrentX = j - 0.5
CurrentY = 0
If Abs(j) > 0 Then Print j
Next j
For k = -10 To 10 Step 0.01
PSet (k, Sin(k)), vbRed
PSet (k, Cos(k)), vbBlue
Next k
2、根据具体需要,调用内部函数,或自定义函数,绘制函数图像。
3、代码供参考:
Me.AutoRedraw = True
Me.Width = 8000: Me.Height = 6000
Me.Scale (-10, 2)-(10, -2)
Line (0, -2)-(0, 2)
Line (-20, 0)-(20, 0)
For i! = -2 To 2 Step 0.5
Line (0, i)-(0.5, i)
CurrentX = -1.8
CurrentY = i
Print i
Next i
For j! = -8 To 10 Step 2
Line (j, 0)-(j, 0.05)
CurrentX = j - 0.5
CurrentY = 0
If Abs(j) > 0 Then Print j
Next j
For k = -10 To 10 Step 0.01
PSet (k, Sin(k)), vbRed
PSet (k, Cos(k)), vbBlue
Next k
展开全部
用描点的方法吧
Form1.PSet (x, Sin(x))
Private Const PI = 3.14159265358979
Private Sub Command1_Click()
w = 5 * PI
h = w * Picture1.Height / Picture1.Width
Picture1.Scale (-w, h)-(w, -h)
k = Picture1.ScaleWidth / Picture1.Width
Debug.Print Picture1.Width
Picture1.Line (-w, 0)-(w, 0)
Picture1.Line (0, -h)-(0, h)
For x = -2 * PI To 2 * PI Step k
Picture1.PSet (x, Sin(x))
Next
End Sub
Form1.PSet (x, Sin(x))
Private Const PI = 3.14159265358979
Private Sub Command1_Click()
w = 5 * PI
h = w * Picture1.Height / Picture1.Width
Picture1.Scale (-w, h)-(w, -h)
k = Picture1.ScaleWidth / Picture1.Width
Debug.Print Picture1.Width
Picture1.Line (-w, 0)-(w, 0)
Picture1.Line (0, -h)-(0, h)
For x = -2 * PI To 2 * PI Step k
Picture1.PSet (x, Sin(x))
Next
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询