Q:

How to declare array from listview1.listitems.count

i am using following code to display chart records from 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

I need something like :
Dim X(1 To Listview1.listitems.count, 1 To 2) As Variant

it will help to add rows in mschart control

A:

Dim with an array requires the dimension argument to be constant (resolvable at compile time), you attempt to use a variable. 
To use a variable, declare an undimensioned array:
Dim X() as variant

Then define its length with ReDim:
ReDim X(1 To Listview1.listitems.count, 1 To 2) '// no type

Or you can simply:
ReDim X(1 To Listview1.listitems.count, 1 To 2) as variant

