Adblock breaks this site

sum numbers in a collection

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

  1. exiled warrior

    exiled warrior Forum Addict
    Banned

    Joined:
    Apr 4, 2006
    Posts:
    585
    Referrals:
    3
    Sythe Gold:
    0
    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
     
  2. Flaming Idiots

    Flaming Idiots Active Member
    Visual Basic Programmers

    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User
    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
     
  3. exiled warrior

    exiled warrior Forum Addict
    Banned

    Joined:
    Apr 4, 2006
    Posts:
    585
    Referrals:
    3
    Sythe Gold:
    0
    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 >


 
 
Adblock breaks this site