471,570 Members | 902 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

sum

How to make a Sum of listBox items?

Hrcko
Jan 2 '06 #1
4 3025
"Hrvoje Voda" <hr*********@luatech.com> a écrit dans le message de news:
dp**********@ss405.t-com.hr...

| How to make a Sum of listBox items?

Assuming all the items in the listbox are string representations of integers
:

{
int total = 0;

foreach (object o in listbox1.Items)
{
total += (int) Convert.ChangeType(o, typeof(int));
}
}

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Jan 2 '06 #2
Or just simply:

int count = listbox.Items.Count;

Cheers
Simon.

"Hrvoje Voda" <hr*********@luatech.com> wrote in message
news:dp**********@ss405.t-com.hr...
How to make a Sum of listBox items?

Hrcko

Jan 2 '06 #3
"Simon Hart" <srhartone@[no spam]yahoo.com> a écrit dans le message de news:
uE****************@TK2MSFTNGP12.phx.gbl...
| Or just simply:
|
| int count = listbox.Items.Count;

Huh ? The term Sum means the total of all the values, not the Count.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Jan 2 '06 #4
"Joanna Carter [TeamB]" <jo****@not.for.spam> wrote in message
news:eK****************@TK2MSFTNGP15.phx.gbl...
"Simon Hart" <srhartone@[no spam]yahoo.com> a écrit dans le message de
news:
uE****************@TK2MSFTNGP12.phx.gbl...
| Or just simply:
|
| int count = listbox.Items.Count;

Huh ? The term Sum means the total of all the values, not the Count.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer


Well it depends on context

If I asked for the sum total of items in the list I'd probably be after the
count. but if I asked for the sum of the items I'd probablt be asking got
the the sum across each item in teh list.

The problme is that on an English newsgroup in a heavily non-English
speaking world then both interpretations are valid and the OP needs to
provide more context.

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
Jan 3 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by William C. White | last post: by
2 posts views Thread by Albert Ahtenberg | last post: by
3 posts views Thread by James | last post: by
reply views Thread by Ollivier Robert | last post: by
1 post views Thread by Richard Galli | last post: by
4 posts views Thread by Albert Ahtenberg | last post: by
1 post views Thread by inderjit S Gabrie | last post: by
2 posts views Thread by Jack | last post: by
3 posts views Thread by Sandwick | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by lumer26 | 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.