VB计算结果画图

来源:百度知道 编辑:UC知道 时间:2024/05/11 15:56:12
我想让VB计算结果画图表示,谁能帮帮我谢谢
QQ165399360

我也许可以帮你?

用point画点,X值取计算进度,Y值取计算进度的结果。

Rem 可显示当前坐标的函数画图,窗体放两个控件,Picture1,Label1,使用默认属性

Option Explicit

Rem 此处给出y=f(x)的函数值,供其他过程调用,可以任意修改为其他函数形式
Private Function Y(ByVal X)
Y = Sin(X)
End Function

Private Sub Form_Activate()
Dim x1, x2, y1, y2
Dim px, py, n, X

Label1.Visible = False
Label1.AutoSize = True
Picture1.AutoRedraw = True
Picture1.Left = 0
x1 = -10 'X坐标轴最右边的值(X轴最大值)
x2 = 15 'X坐标轴最左边的值(X轴最小值)
y1 = -1 'X坐标轴最下边的值(最小值)
y2 = 1 'X坐标轴最上边的值(最大值)

Picture1.ScaleWidth = X - x1
Picture1.ScaleHeight = y2 - y1
px = Picture1.Width / Picture1.ScaleWidth '设置X轴单位刻度的实际长度
py = Picture1.Height / Picture1.ScaleHeight '设置Y轴单位刻度的实际长度
Picture1.Scale (x1, y2)-(x2, y1) '初始化坐标系
Picture1.Line (x1, 0)-(x2, 0), vbRed ' 画X轴
Picture1.Line (0, y1)-(0, y2), vbRed ' 画Y轴
Rem 以上代码是初始化坐标系

n = 0.001 'X轴上取