472,144 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,144 software developers and data experts.

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!
Jul 5 '12 #1
2 3499
Guido Geurs
767 Expert 512MB
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.
Jul 5 '12 #2
8,435 Expert 8TB
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...
Expand|Select|Wrap|Line Numbers
  1. For x = 0 to listbox.ListCount - 1
  2.   Tally = Tally + Val(listbox.List(x))
  3. Next
Note the odd start/end values for the loop, thanks to the silly zero-based index that MS decided to use.
Jul 7 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

30 posts views Thread by priya | last post: by
6 posts views Thread by Tim Whelan via DotNetMonster.com | last post: by
2 posts views Thread by John Dalberg | last post: by
7 posts views Thread by zhouchengly | last post: by
4 posts views Thread by Gacha | last post: by
6 posts views Thread by Chuck Anderson | last post: by
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.