Click to See Complete Forum and Search --> : Using 2D array to populate MSchart


faamugol
03-29-2004, 04:17 AM
Hello ,


I' m using a 2D array to populate a MSchart


Dim dataArray(), arrTMP
Dim length, el, strString

strString = "12:00;0.001;12:15;0.000;12:30;0.0002;12:45;0.0003"

arrTMP = Split(strString, ";")
length = 1
' arrange all elements into 2-dimensional array


For el = 0 To UBound(arrTMP) Step 2
ReDim Preserve dataArray(2, lengte)
dataArray(1, lengte) = arrTMP(el)
dataArray(2, lengte) = arrTMP(el + 1)
lengte = lengte + 1 ' increase index counter
Next

MSChart1(1).ChartData = dataArray

but the problem is for a MSchart the array must be filled as follow:

For el = 0 To UBound(arrTMP) Step 2
ReDim Preserve dataArray(lengte,2)
dataArray(lengte,1) = arrTMP(el)
dataArray(lengte,2) = arrTMP(el + 1)
lengte = lengte + 1 ' increase index counter
Next

and here the problem is:

In VBScript you can ReDim any array including multi-dimentioned arrays - but only the last dimention can be increased


And me I need to increase the first dimention..

Can somebody help me to solve that..?

thank you in advance for your help

tomhartland
03-29-2004, 05:04 AM
faamugol, I did explain how to solve this last Friday.

Set the size of the array before the loop using the UBound of the array holding the split strings...

ReDim dataArray( (UBound(arrTMP)+1)/2,2)
For el = 0 To UBound(arrTMP) Step 2
dataArray(length,1) = arrTMP(el)
dataArray(length,2) = arrTMP(el + 1)
length = length + 1 ' increase index counter
Next

faamugol
03-29-2004, 11:02 AM
thanks,

I'm going to try