By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,162 Members | 1,050 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,162 IT Pros & Developers. It's quick & easy.

Adding values together

P: 11
Hi all i have a bit of script that i am working on that adds the numbers out of the SQL database together. I can get it to give me like 30.000.45 when i add 30.00 and 0.45 (say two prices. Really i want it to come out with 30.45.
Expand|Select|Wrap|Line Numbers
  1. Dim intNumber
  2. Dim intTotal
  3. Do While Not rsNumbers.EOF
  4. intNumber = rstesr("RSprice")
  5. intNumber = FormatNumber(intNumber,2)
  6. Response.Write intNumber
  7. intTotal = intTotal + intNumber
  8. intNumber = 0
  9. RStest.MoveNext
  10. Loop
  11.  
Its where i want to add like a shopping cart together.
Aug 15 '12 #1
Share this Question
Share on Google+
1 Reply


P: 11
Scrap that i changed codes and instead of using "INT" i used CSng and the code below. i knew i must of not been far off

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim CSngSum
  3. Sum = 0
  4. Do While Not RStest.EOF
  5.   CSngSum = CSngSum + CSng(RStest("RSprice"))
  6.   RStest.MoveNext
  7. Loop
  8.  
  9. Response.Write(CSngSum)
  10. %>
  11.  
Aug 15 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.