Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. ListBox

ListBox

Scheduled Pinned Locked Moved C#
question
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    minniemooo
    wrote on last edited by
    #1

    hi, How do I add numbers in a listBox? eg. I have a list of numbers in my listbox and I want to add them and place the result in a textBox.

    P L 2 Replies Last reply
    0
    • M minniemooo

      hi, How do I add numbers in a listBox? eg. I have a list of numbers in my listbox and I want to add them and place the result in a textBox.

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      Use a variable to maintain a running sum. Iterate through each item in the listbox. For each iteration, convert the value of the current item to a number and add its value to the current value of the running sum variable. Finally, write the value of the running sum variable to your textbox. Paul

      1 Reply Last reply
      0
      • M minniemooo

        hi, How do I add numbers in a listBox? eg. I have a list of numbers in my listbox and I want to add them and place the result in a textBox.

        L Offline
        L Offline
        laddie 0
        wrote on last edited by
        #3

        Here is the code if you require :) int sum =0; for(int i=0;i

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups