How to sum up all the integer values enteres in a list box?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Loginalyn
    New Member
    • Jul 2012
    • 1

    How to sum up all the integer values enteres in a list box?

    i am doing a Point of Sales sytem.i am having trouble on how will i add all the integer values entered in a list box by clicking a command button with a corresponding integer value.
    i want to compute the sum of those integers when i click the compute button. can someone give me an idea or a sample code?
    Thanks in advance!
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    Can you attach in Bytes an example of the data in the list and what the result must be after computation?
    Not to much values please, just to have an idea what you want to process.
    If the data is confidential, please replace it with fictive but representative values.

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Assuming we're talking about VB6 here, the simplest way to tally up the numbers in a list box would to use a loop something like...
      Code:
      For x = 0 to listbox.ListCount - 1
        Tally = Tally + Val(listbox.List(x))
      Next
      Note the odd start/end values for the loop, thanks to the silly zero-based index that MS decided to use.

      Comment

      Working...