sum numbers in a collection

Discussion in 'Programming General' started by exiled warrior, Dec 1, 2008.

sum numbers in a collection
  1. Unread #1 - Dec 1, 2008 at 2:58 AM
  2. exiled warrior
    Joined:
    Apr 4, 2006
    Posts:
    585
    Referrals:
    3
    Sythe Gold:
    0

    exiled warrior Forum Addict
    Banned

    sum numbers in a collection

    i need to write a sub procedure that adds all the numbers in a collection. if it helps at all my program will know how many items are in the collection.

    am i looking for a for/next loop an array or wat?

    pls help
     
  3. Unread #2 - Dec 1, 2008 at 3:03 AM
  4. Flaming Idiots
    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User

    Flaming Idiots Active Member
    Visual Basic Programmers

    sum numbers in a collection

    If you are using VB 2008, you should just be able to do this:
    Code:
    Dim SumOfCollection = Collection.Sum()
    If not, a for each loop like this would work:
    Code:
    Dim Sum as Integer = 0
    For Each Value As Integer In Collection
        Sum += Value
    Next
     
  5. Unread #3 - Dec 1, 2008 at 7:12 PM
  6. exiled warrior
    Joined:
    Apr 4, 2006
    Posts:
    585
    Referrals:
    3
    Sythe Gold:
    0

    exiled warrior Forum Addict
    Banned

    sum numbers in a collection

    i dont got 08

    wen i try to use the for statement u gave me it says the "+" is not defined for type integer and coupons.aClass(this is my collection)

    how do i define it...?
     
< Stuck can some one please help me | Windows Live Messenger - Desktop contact list >

Users viewing this thread
1 guest


 
 
Adblock breaks this site