Results 1 to 7 of 7

Thread: Sum Array from Database

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2007
    Posts
    124

    Question Sum Array from Database

    Hello everyone!

    I have a database field that stores values like this format "1,3,1,6,0,2,7"

    Now i want to perform a SUM function on that field.
    For example, the query found 3 results so lets say the values are:
    Code:
        Field 1   |    Field 2
    ------------  | ------------
    2,1,0,1,1,5,2 |
    0,0,5,4,0,0,3 |
    1,1,4,0,0,1,0 |
    ------------  | ----------
    3,2,9,5,1,6,5  << expected output
    I want to perform a sum function where the output would be like that.


    Here is what i started i don't know if it's correct.

    Code:
    Dim myArr() As String
    Dim tmp(6) As String
    
    For y = 1 To rs.RecordCount
           
        myArr = Split(rs!FieldFromDbase, ",")
        tmp(y - 1) = tmp(y - 1) + myArr(y - 1)
        rs.Movenext
    
    Next y
    There is a flaw in this code. Can somebody help me modify this so that i can sum each element in the array?
    Last edited by Erroneous; Jul 10th, 2010 at 10:52 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width