Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

ASP Vbscript - Sum array

Posted on 2003-03-04
5
Medium Priority
?
2,042 Views
Last Modified: 2012-06-21
I use a SQL query to build an array, I then loop through the data collected, and display it.

Without using the SUM command in my SQL statement how can I SUM the array.

the code is as follows

For j = 0 to UBound(vntRowst,2)

ClientRowID=vntRowst(0,j)

sSQLD = "SELECT fldRow_ID,fldInterview_Date,ROUND(fldAmount,2),ROUND(fldGST,2),ROUND(fldTotal_Amount,2),fldInterview_Start_Time,fldBooking_Row_id,fldTotal_Amount FROM tblClient_Invoices_Line WHERE fldClient_Invoices_Row_ID = "&ClientRowID&" ORDER BY fldInterview_Date ASC"  
         
vntRowsD = TIBS.GetSQLRows(Cstr(sSQLD))

Next

Before the next I write the arrays to screen as follows
response.write vntRowsD(0,j) etc

What I would then like to do is add the values
ie X = vntRowsD(0,j) + vntRowsD(j+1) until j reaches its ubound limit.

How can this be done
0
Comment
Question by:DCPAus
5 Comments
 
LVL 7

Expert Comment

by:markhoy
ID: 8063991
Are you trying to do something like this:

Const COLUMN_COUNT = 3


... get the recordset from a query ...
allRecords = RS.GetRows ' convert it to an array!
RS.Close ' no further need of it

' how many records?
recMax = UBound( allRecords, 2 )

' then how many rows from those records?
rowCount = (recMax + 1) / COLUMN_COUNT

http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_20489479.html
0
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 200 total points
ID: 8064458
You should be able to do the following:

numTotal = 0

for j=0 to UBound(vntRowsD,1)
   intTotal = intTotal + vntRowsD(j,0)
next


or

for j=0 to UBound(vntRowsD,2)
   intTotal = intTotal + vntRowsD(0,j)
next


Fritz the Blank
0
 
LVL 3

Expert Comment

by:keystrokes
ID: 8065177
You are trying to add an element vntRowsD(0,j) to vntRowsD(j+1) which is not a valid element reference.  What are you trying to add exactly?  Why wouldn't you use SUM in your SQL?  
0
 

Author Comment

by:DCPAus
ID: 8070798
Simple and exactly what I needed

Thanks
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 8072454
Glad to have helped,

Fritz the Blank
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Screencast - Getting to Know the Pipeline
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses
Course of the Month11 days, 23 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question