Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 23rd, 2004, 11:47 AM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hcweb
Default Total Value from a Loop

How can you get the total value acquired in a loop statement without knowing the number of records involved? i.e.:

Do While Not objRS.EOF
    Response.Write objRS("value") & "<br>"
objRS.MoveNext
Loop

results in 3 records like so,
10
20
30

How can you total those figures after the loop to show only 60?
 
Old August 23rd, 2004, 01:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Code:
Dim TotVal
TotVal=0
Do While Not objRS.EOF
    Response.Write objRS("value") & "<br>"
    TotVal = TotVal + objRS("value")
objRS.MoveNext
Loop
Response.Write TotVal
This is how you could do that.

Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old August 23rd, 2004, 02:56 PM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hcweb
Default

Worked like a champ! Your help is very much appreciated!

Thanks,
Chris





Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting the Total northwind XSLT 1 April 26th, 2007 03:40 AM
Sub Total Rjh Reporting Services 0 June 21st, 2006 04:11 PM
sub report total sanjay_jadam Crystal Reports 1 June 24th, 2005 12:55 PM
nested while loop doesn't loop hosefo81 PHP Databases 5 November 12th, 2003 08:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.