Array question- HELP!

Results 1 to 2 of 2

Thread: Array question- HELP!

  1. #1
    Join Date
    Dec 1969

    Default Array question- HELP!

    Once I have pulled in a recordset into an array variable, how can I easily sum the values in one of the array&#039;s fields? For example, summing the Y field values in Array(X,Y).<BR><BR>Is there some type of SUM command I could use?<BR><BR>Thanks- Tim

  2. #2
    Join Date
    Dec 1969

    Default Good old FOR...NEXT

    And I don&#039;t *REALLY* think you mean summing the Y values from Array(X,Y), since if you used GetRows to convert the recordset to an array, that is the *rows* variable.<BR><BR>Let&#039;s assume you want to sum the values of the third field in every row.<BR><BR>So:<BR><BR>&#060;%<BR>sum = 0<BR>For row = 0 To UBound( theArray, 2 )<BR>&nbsp; &nbsp; sum = sum + theArray( 2, row ) &#039; remember, field 3 is in slot 2! <BR>Next<BR>%&#062;<BR><BR>Naturally, you could sum more than one column at a time:<BR><BR>&#060;%<BR>sum2 = 0<BR>sum6 = 0<BR>For row = 0 To UBound( theArray, 2 )<BR>&nbsp; &nbsp; sum2 = sum2 + theArray( 2, row )<BR>&nbsp; &nbsp; sum6 = sum6 + theArray( 6, row )<BR>Next<BR>%&#062;<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts