counting shopping cart 2d Array items in asp-classic

AXMelaCalisip

New Member
I have a shopping cart that using 2d array \[code\]Cart(3, 20)\[/code\] to store user shop in a session.
It storing data like this:\[code\] Cart(0,0) = Product_ID Cart(1,0) = Product_Name Cart(2,0) = Product_Price Cart(3,0) = Product_Qty\[/code\]I want to count Items based on product_id ( we have not repetitive product_id)I found a function here:\[code\]Function UniqueEntryCount(SourceRange) Dim MyDataset Dim dic Set dic=Server.CreateObject("Scripting.Dictionary") MyDataset = SourceRange For i = 1 To UBound(MyDataset, 2) if not dic.Exists(MyDataset(0, i)) then dic.Add MyDataset(0, i), "" Next UniqueEntryCount = dic.Count Set dic = NothingEnd Function\[/code\]But one problem is remain, When my Cart is empty, it show me 1
How can solved it?
 
Back
Top