FOR EACH - NEXT SubTotal Calculation

S

Sparky Arbuckle

Hello All! My problem is trying to calculate SubTotal in my FOR EACH
NEXT Loop. I am looping through depending on how many of each different
item is in the user's shopping cart. I am using each Item ID in the
cart to display the appropriate image, artist name, and price
information for each item in the cart. I am running into problems when
I try and display the subtotal and add a count of each item in the
shopping cart. More importantly I am trying to come up with the
SubTotal. Here is the snippet of code for my loop:

<----------------------------------------------------->

Dim MyCookie as new httpCookie(MyCookieName)
Dim intCount as integer = 0
Dim intSubTotal as integer = 0


Dim objConn as new
OLEDBConnection(ConfigurationSettings.AppSettings("StrConnection"))
Dim strSQL as string = "SELECT ITEM ID, imageDIR, Price, ReleaseDate
FROM tblDescription WHERE "

FOR EACH myItem as DictionaryEntry in gtCart
intCount = intCount + 1
intSubTotal = intSubtotal * .8
MyCookie.Values(myItem.Key) = myItem.Value

strSQL += "ITEMID= '" & myItem.Key & "'"

IF intCount < gtCart.Count
strSQL += " OR "

ELSE

strSQL += ";"
END IF

NEXT

<----------------------------------------------------->

The FOR EACH NEXT Loop that I have listed works magnificently for
figuring out if I have multiple items in my shopping cart and displays
everything perfectly. I try to reference intSubTotal (20% off each) in
the body of my page (nested inside of my FORM runat="Server") and it
does not work. Can anyone shed some light on how to go about creating a
variable for SubTotal and displaying it on my page?

SideNote: myItem.Value is how many of each ITEMID is in the shopping
cart. How can I reference this in my DataGrid?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top