Hello,
I am trying pull data from a 2-dimensional array but am getting an error like:

Microsoft VBScript runtime error '800a0009'
Subscript out of range: '1'
/test.asp, line 39

the message gives the line number but i don't see whaats wrong with it

this is a simplified version of what i'm trying to do:
i want to get a list of black cars from the first array.

<%
Dim cars(1,4), blcar(), i
'cars
cars(0,0) = "toyota"
cars(1,0) = "white"
cars(0,1) = "ford"
cars(1,1) = "black"
cars(0,2) = "porshe"
cars(1,2) = "red"
cars(0,3) = "bmw"
cars(1,3) = "yellow"
cars(0,4) = "mazda"
cars(1,4) = "black"

 
Response.Write "<table border='1'>" 
Response.Write "<tr><td>Row</td><td>Car</td><td>Color</td></tr>" 

For i = 0 to UBound(cars,2) 
Response.Write "<tr><td>" & i & "</td>" 
Response.Write "<td>" & cars(0,i) & "</td>" 
Response.Write "<td>" & cars(1,i) & "</td></tr>" 
Next 
Response.Write "</table>"
Response.Write "<B>Black cars</B>"

'list black cars
Redim  blcar(0)
For i = 0 to UBound(cars,2) 
	If cars(1,i) = "black" then
		blcar(i)= cars(0,i)            'This is the problem line
		Redim Preserve blcar(i+1)
	End If 
Next 

Response.Write "<p>" 
For i = 0 to UBound(blcar) 
              Response.Write  blcar(i) & " . " 
Next 
%>

The second array has to be dynamis because in the real page the list will change.

Please let me know what am i doing wrong here

Thank you

Sorted.

the last part is supposed to look like this

Redim  blcar(1)
x = 0
 
For i = 0 to UBound(cars,2) 
	If cars(1,i) = "black" then
		Redim Preserve blcar(x+1)
		blcar(x)= cars(0,i)
		x = x+1

	End If 
Next 

Response.Write "<p>" 
For i = 0 to UBound(blcar)
Response.Write "<td>" & blcar(i) & " . " 
Next
This question has already been answered. Start a new discussion instead.