468,510 Members | 1,735 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,510 developers. It's quick & easy.

Adding values together

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
1 1997
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.

Similar topics

10 posts views Thread by Sunny K | last post: by
3 posts views Thread by Aaron Ackerman | last post: by
15 posts views Thread by crjunk | last post: by
4 posts views Thread by David Plotts | last post: by
4 posts views Thread by ranjini ns | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.