ben 4 öğeler sonra, hala öğeleri ekleyebilir, sorun buArtan Dizi Boyut dinamik
localCart(CARTPID,i) = productId
localCart(CARTPRICE,i) = productPrice
localCart(CARTPQUANTITY,i) = 1
gibi dinamik olarak bu diziye öğeler eklemek
CONST CARTPID = 0
CONST CARTPRICE = 1
CONST CARTPQUANTITY = 2
dim localCart(3,20)
ASP
bu dizi var ama UBound daima geri dönüyor.Bu dizinin boyutunu çalışma zamanında artırmak istiyorum, böylece UBOUND en son değeri döndürebilir.
Lütfen bunu nasıl yapacağımı bildirin. İşte benim tam kodu
'Define constants
CONST CARTPID = 0
CONST CARTPRICE = 1
CONST CARTPQUANTITY = 2
'Get the shopping cart.
if not isArray(session("cart")) then
dim localCart(3,20)
else
localCart = session("cart")
end if
'Get product information
productID = trim(request.QueryString("productid"))
productPrice = trim(request.QueryString("price"))
'Add item to the cart
if productID <> "" then
foundIt = false
for i = 0 to ubound(localCart)
if localCart(CARTPID,i) = productId then
localCart(CARTPQUANTITY,i) = localCart(CARTPQUANTITY,i)+1
foundIt = true
exit for
end if
next
if not foundIt then
for i = 0 to 20
if localCart(CARTPID,i) = "" then
***ReDim Preserve localCart(UBound(localCart, 1) + 1,20)***
localCart(CARTPID,i) = productId
localCart(CARTPRICE,i) = productPrice
localCart(CARTPQUANTITY,i) = 1
exit for
end if
next
end if
end if
Teşekkürler, bu çalışıyor ama değerleri koruyamıyorum. En kısa sürede ben ReDim koru kullandıkça, ben bu hatayı alıyorum: aralık /prices_test.asp, çizgi dışına Microsoft VBScript çalışma zamanı hatası '800A0009' simge hata – VJV
kodunuzu herkes görsün göstermek Orijinal mesaja tam kod ekledim. – Robert
sayesinde oluştuğunu nerede 102 – VJV