關於vb script的問題
我在試dreamweaver的購物車網頁
但在測試階段發生了問題
問題是陣列索引超出範圍
我是個程式白痴不知道要怎麼改
很急著想知道怎麼改
請客位大大如果知道跟我說一下
以下是我的程式碼
<%
CONST CC_ProductID = 0
CONST CC_Quantity = 1
CONST CC_Name = 2
CONST CC_Price = 3
CONST CC_UniqueKey = 4
if Request.Cookies("CharonCart") = "" then
dim CCcart(5,50)
else
CCcart=CookieToCart("CharonCart")
end if
CCcart_SubTotal=0
CCcart_numItems=0
CCcart_Shipping=0
CCcart_Discount=0
CCcart_SalesTax=0
isFound=false
for i=0 to ubound(CCcart,2)
if CCcart(CC_ProductID,i) <> "" then
isFound=true
CCcart_SubTotal=CCcart_SubTotal + (CCcart(CC_Quantity,i)*CCcart(CC_Price,i))
CCcart_numItems=CCcart_numItems + 1
end if
next
function CCcart_LineTotal
CCcart_LineTotal=CCcart(CC_Quantity,i)*CCcart(CC_Price,i)
end function
function CCcart_GrandTotal
CCcart_GrandTotal=CCcart_SubTotal + CCcart_Shipping + CCcart_SalesTax - CCcart_Discount
end function
function CartToCookie(thearray,cookiename)
on error resume next
mystring=""
for j=0 to ubound(CCcart,2)
if CCcart(CC_ProductID,j) <> "" then
for i=0 to 5
mystring=mystring & CCcart(i,j) & "^"
next
mystring=left(mystring,len(mystring)-1)
mystring=mystring & "|"
end if
next
mystring=left(mystring,len(mystring)-1)
Response.Cookies(cookiename)=mystring
end function
function CookieToCart(cookiename)
dim myarray(5,50)
mystring=Request.Cookies(cookiename)
productarray=split(mystring,"|")
for j=0 to ubound(productarray)
itemarray=split(productarray(j),"^")
for i=0 to 5
if itemarray(i) <> "" then
myarray(i,j)=itemarray(i)
else
myarray(i,j)=null
end if
next
next
CookieToCart=myarray
end function
%>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 210.201.223.192
推
01/02 14:47, , 1F
01/02 14:47, 1F
Visual_Basic 近期熱門文章
PTT數位生活區 即時熱門文章