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. Visual Basic
  4. Addition

Addition

Scheduled Pinned Locked Moved Visual Basic
question
6 Posts 5 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.
  • D Offline
    D Offline
    dexter9703
    wrote on last edited by
    #1

    How can I the sum of say(Items in a listbox): 6.78 9.05 5.56 4.45 displayed in a textbox with the answer given with 2 decimal places.

    A C 2 Replies Last reply
    0
    • D dexter9703

      How can I the sum of say(Items in a listbox): 6.78 9.05 5.56 4.45 displayed in a textbox with the answer given with 2 decimal places.

      A Offline
      A Offline
      AliAmjad
      wrote on last edited by
      #2

      Iterate through the items in a Listbox by using its Items property and use a variable who receives the values and add them then display that variable in the Textbox you can iterate by using For Each loop. You can use FormatNumber function to display values up to two decimal places. Hope it helps !

      AliAmjad(MCP)

      D 1 Reply Last reply
      0
      • A AliAmjad

        Iterate through the items in a Listbox by using its Items property and use a variable who receives the values and add them then display that variable in the Textbox you can iterate by using For Each loop. You can use FormatNumber function to display values up to two decimal places. Hope it helps !

        AliAmjad(MCP)

        D Offline
        D Offline
        dexter9703
        wrote on last edited by
        #3

        Can you give an example please

        P T 2 Replies Last reply
        0
        • D dexter9703

          Can you give an example please

          P Offline
          P Offline
          Paul Conrad
          wrote on last edited by
          #4

          AliAmjad pretty much spelled it out for you.

          "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

          1 Reply Last reply
          0
          • D dexter9703

            Can you give an example please

            T Offline
            T Offline
            The ANZAC
            wrote on last edited by
            #5

            Dim sum as decimal for i as integer = 0 to me.listbox1.count - 1 sum += me.listbox1.items.item(i) next i

            Please check out my articles: The ANZAC's articles

            1 Reply Last reply
            0
            • D dexter9703

              How can I the sum of say(Items in a listbox): 6.78 9.05 5.56 4.45 displayed in a textbox with the answer given with 2 decimal places.

              C Offline
              C Offline
              Cedrickdeorange
              wrote on last edited by
              #6

              Use Decimal for a variable then, as was said, Iterate through.

              Regards Zeldacat

              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