Math problems/ operands from listbox

Posted on 2008-11-18
Last Modified: 2013-11-13
I need a code that would take numbers from a list box and solve them when i press add or multiply I have been working on this for hours and can't get it right......please help.
Question by:progbeginner
    LVL 100

    Expert Comment

    What code do you have thus far?

    LVL 2

    Accepted Solution

    As I understand It's should be like that
            private void buttonPlus_Click(object sender, EventArgs e)
                Int32 sum = 0;
                foreach (string s in listBox1.Items)
                    Int32 value;
                    if (Int32.TryParse(s, out value))
                        sum += value;

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Prime numbers are natural numbers greater than 1 that have only two divisors (the number itself and 1). By “divisible” we mean dividend % divisor = 0 (% indicates MODULAR. It gives the reminder of a division operation). We’ll follow multiple approac…
    A short article about problems I had with the new location API and permissions in Marshmallow
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now