adding up my totals logic, help

1. Senior Member
Join Date
Dec 1969
Posts
1,045

## adding up my totals logic, help

I have a loop that displays records. One of the columns I&#039;m returning back is a \$total sale amount. I then add the amounts up during the loop. I then want to apply a shipping fee depending on the total sale. The below code represents the logic however I am getting back inconsistent results that go against my logic:<BR><BR>&#060;% <BR>Dim TotalCost : TotalCost = 0<BR>Do While Not rsShoppingCart.EOF <BR>TotalCost = TotalCost + CDbl(rsShoppingCart("total") )<BR>%&#062;<BR><BR>blah blah..<BR><BR>&#060;% <BR>rsShoppingCart.MOVENEXT <BR>LOOP<BR>%&#062;<BR><BR>In SQL I know that you can use the BETWEEN clause, can I also do the same thing in ASP?<BR><BR>&#060;%IF TotalCost &#062;= "10" AND TotalCost &#060;= "30" THEN<BR>strShipping = TotalCost + 1<BR>strAmount = "\$1.00"<BR>ELSEIF TotalCost &#062;= "31" AND TotalCost &#060;= "60" THEN<BR>strShipping = TotalCost + 2<BR>strAmount = "\$2.00"<BR>ELSEIF TotalCost &#062;= "61" THEN<BR>strShipping = TotalCost + 3<BR>strAmount = "\$3.00"<BR>ELSE<BR>strShipping = TotalCost<BR>strAmount = "\$--" <BR>END IF<BR>Response.Write “Shipping: ” & strAmount & “Total Sale: ” & strShipping<BR>%&#062;<BR><BR><BR>

2. Senior Member
Join Date
Dec 1969
Posts
286

## RE: adding up my totals logic, help

You don&#039;t need the between clause.<BR>I think where you&#039;re messing up is if the total is \$30.95<BR>It doesn&#039;t evaluate to any of your if statements<BR>Try this instead<BR><BR>IF TotalCost &#060;= 10 THEN<BR>strShipping = TotalCost<BR>strAmount = "\$--"<BR>ELSEIF TotalCost &#060;= 30 THEN<BR>strShipping = TotalCost + 1<BR>strAmount = "\$1.00"<BR>ELSEIF TotalCost &#060;= 60 THEN<BR>strShipping = TotalCost + 2<BR>strAmount = "\$2.00"<BR>ELSE<BR>strShipping = TotalCost + 3<BR>strAmount = "\$3.00"<BR>END IF

3. Senior Member
Join Date
Dec 1969
Posts
96,118

## Correct, *AND*...

...you will notice that the Saint got rid of the bogus quotes around your comparison numbers. *NUMBERS* should *never* have quotes around them, in any language.<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•