?
Solved

ASP Vbscript - Sum array

Posted on 2003-03-04
5
Medium Priority
?
1,957 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

752 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