我使用以下代码显示Listview1
中的图表记录Dim X(1 To 5, 1 To 2) As Variant
Dim i As Integer, j As Integer
j = 1
For i = 1 To Listview1.ListItems.Count
X(j, 1) = Listview1.ListItems(i).Text
X(j, 2) = Listview1.ListItems(i).SubItems(1)
j = j + 1
Next i
MSChart1.ChartData = X
MSChart1.chartType = 1
我需要类似的东西:
Dim X(1 To Listview1.listitems.count, 1 To 2) As Variant
它将有助于在mschart控件中添加行
答案 0 :(得分:2)
Dim
要求维度参数保持不变(在编译时可解析),您尝试使用变量。
要使用变量,请声明一个未扩展的数组:
Dim X() as variant
然后使用ReDim
:
ReDim X(1 To Listview1.listitems.count, 1 To 2) '// no type
或者你可以简单地说:
ReDim X(1 To Listview1.listitems.count, 1 To 2) as variant