www.webdeveloper.com
Results 1 to 3 of 3

Thread: Using 2D array to populate MSchart

  1. #1
    Join Date
    Mar 2004
    Location
    Holland
    Posts
    139

    Using 2D array to populate MSchart

    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

  2. #2
    Join Date
    Nov 2003
    Location
    Derby, UK
    Posts
    87
    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...
    Code:
    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
    I am not young enough to know everything - Oscar Wilde

  3. #3
    Join Date
    Mar 2004
    Location
    Holland
    Posts
    139
    thanks,

    I'm going to try

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles