vb利用MatrixVB插件画图问题???
描点数据通过过listview控件输入,代码如下:
Function simulation()
Dim h As Variant
Dim i, j As Integer
Dim x(), y() As Double
Dim a, b
Const pi = 3.1415926 '定义pi的值
ReDim x(1, 1 To ListView1.ListItems.Count), y(1, 1 To ListView1.ListItems.Count) As Double
For i = 1 To ListView1.ListItems.Count
x(1, i) = ListView1.ListItems(i).SubItems(1) ’存储第一列值
y(1, i) = ListView1.ListItems(i).SubItems(1) * Cos(pi / 180 * ListView1.ListItems(i).SubItems(2)) ’存储第二列值
xlabel ("distance")
ylabel ("height")
Next i
a = mabs(x)
b = mabs(y)
h = plot(a, b)
End Function
问题描述:本来是想通过listview输入数据,共两列数据,分别存在数组里面,再利用MatrixVB的mabs()函数将数组转化为矩阵,调用plot()函数画图,现在总是报错下边越界,调试看了,for循环完后,i = ListView1.ListItems.Count,修改为:
,不报越界,图形还是出不来,请教下问题出在哪里?
Function simulation()
Dim h As Variant
Dim i, j As Integer
Dim x(), y()
Dim a, b
Const pi = 3.1415926 '定义pi的值
ReDim x(1, 1 To ListView1.ListItems.Count), y(1, 1 To ListView1.ListItems.Count) As Double
For i = 1 To ListView1.ListItems.Count
x(1, i) = ListView1.ListItems(i).SubItems(1)
y(1, i) = ListView1.ListItems(i).SubItems(1) * Cos(pi / 180 * ListView1.ListItems(i).SubItems(2))
If j = ListView1.ListItems.Count Then
Exit Function
End If
xlabel ("distance")
ylabel ("height")
Next i
a = mabs(x)
b = mabs(y)
h = plot(a, b)
End Function
vb 图形 MatrixVB
补充:VB , 控件