' dim variables
dim strString, i, el
dim arrArray(), arrTMP
' set init values
i = 0
strString = "12:00;10;12:15;20;12:30;30;12:45;40;13:00;50"
' split string into temporary 1-dimensional array
arrTMP = Split(strString,";")
' arrange all elements into 2-dimensional array
for el = 0 to Ubound(arrTMP) step 2
ReDim Preserve arrArray(2,i)
arrArray(1,i) = arrTMP(el)
arrArray(2,i) = arrTMP(el+1)
i = i + 1 ' increase index counter
' display arrARRAY contents:
Response.Write "<br>FINAL Array has " & i & " elements:"
for x = 0 to i-1 ' i-1 to undo the last increase in the For..Next loop
Response.Write "<br> Time: " & arrArray(1,x) & " - score: " & arrArray(2,x)
! REMARK: with this example, your string should NOT end with an ";" because this will generate a VBScript error on the line 'arrArray(2,i) = arrTMP(el+1)' (-> no element).
If your string does end with a trailing ";" you need to add some code to prevent the error (.. maybe just cut the trailing ';' ).
This is one way to go, there must be 100 other ways to do the same thing.
Strange - I've ran the code on my server before posting it and it worked fine - and I don't really see where the problem could be ...
What platform are you using?
I am running this in a VBscript ASP page on an IIS 5.0.
The problem seems to be the indexes (2, i) but since it's a ReDim of the array, I don't see how the i could be 'out of range'.
In VBScript you can ReDim any array including multi-dimentioned arrays - but only the last dimention can be increased.
So this would be valid: ReDim arrTMP(6,2,2,8,i)
This would NOT: ReDim arrTMP(i,2,2,8,10)
Can you check the Help file of your platform for the Dim / ReDim function? Maybe there is a syntax difference ..