We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Totalling List Box Contents

Last post 03-14-2008 8:32 AM by rajeshthangarasu. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 03-13-2008 10:33 AM

    • paulirv13
    • Not Ranked
    • Joined on 03-13-2008
    • United Kingdom
    • New Member
    • Points 10

    Totalling List Box Contents

     

    Hi, I basically want to add up the contents of a list box (in VB6) and display it in a textbox, it will only be numbers in the list.

    Can anyone help?

    thanks  =Paul 

    • Post Points: 10
  • 03-14-2008 8:32 AM In reply to

    Re: Totalling List Box Contents

     I dont know VB so i have typed the code in C#

    Try this  

    private void button1_Click(object sender, EventArgs e)
            {
                int a;
                int b = 0;

                for (int i = 0; i < listBox1.Items.Count ; i++)
                {
                    a = Convert.ToInt32(listBox1.Items[i]);
                    b = b + a;
                }
                textBox1.Text = b.ToString();
            }

    • Post Points: 5
Page 1 of 1 (2 items)