There's something fundamental about declaring arrays in VBscript that I'm just not getting. The code below is supposed to take strBasket (when live, this will be a session variable but for testing I'm hardcoding it) and split it up into a 2-dimensional array.
I've tried declaring aBasket as it is, and with dimensions in, ie:
aBasket = Array(50,2)
I've been through and response.written every other variable it's dealing with: i, myBasketItem(0), myBasketItem(1) - the lot. Everything is as it should be, but I still get an error, "Subscript out of range" when I try to add anything to my aBasket array (the line marked in bold below).
What am I doing wrong?
I've tried declaring aBasket as it is, and with dimensions in, ie:
aBasket = Array(50,2)
I've been through and response.written every other variable it's dealing with: i, myBasketItem(0), myBasketItem(1) - the lot. Everything is as it should be, but I still get an error, "Subscript out of range" when I try to add anything to my aBasket array (the line marked in bold below).
What am I doing wrong?
Code:
Dim strBasket, aBasketItems, myBasketItem, strID, strQuantity, aBasket, strID_list aBasket = Array() strBasket="1-5_2-10_3-15" if strBasket&""<>"" then if inStr(strBasket,"_") then aBasketItems=split(strBasket, "_") for i=lBound(aBasketItems) to uBound(aBasketItems) myBasketItem=split(aBasketItems(i), "-") [B]aBasket(i,0)=myBasketItem(0)[/B] aBasket(i,1)=myBasketItem(1) next else myBasketItem=split(strBasket, "-") aBasket(0,0)=myBasketItem(0) aBasket(0,1)=myBasketItem(1) end if end if
Comment