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. problem with increment decimal value

problem with increment decimal value

Scheduled Pinned Locked Moved C#
help
2 Posts 2 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
    Mr Kode
    wrote on last edited by
    #1

    i have datagrid contains 4 columns , one of them takes decimal datatype i want to increment this value each time to get the sum string name; decimal price, due; int count; name = txtSelectedItem.Text; price =decimal.Parse( lblPrice.Text); count =int.Parse( txtUnitOrder.Text); due = decimal.Parse(lblDue.Text); DGSelectedItems.Rows.Add( name,price,count,due); decimal sum = due++; txtSum.Text = sum.ToString(); the value didn`t incremented but replaced regards in advance

    M 1 Reply Last reply
    0
    • M Mr Kode

      i have datagrid contains 4 columns , one of them takes decimal datatype i want to increment this value each time to get the sum string name; decimal price, due; int count; name = txtSelectedItem.Text; price =decimal.Parse( lblPrice.Text); count =int.Parse( txtUnitOrder.Text); due = decimal.Parse(lblDue.Text); DGSelectedItems.Rows.Add( name,price,count,due); decimal sum = due++; txtSum.Text = sum.ToString(); the value didn`t incremented but replaced regards in advance

      M Offline
      M Offline
      Matthew Butler 0
      wrote on last edited by
      #2

      Mr.Kode wrote:

      decimal sum = due++;

      due is incremented after is is assigned to sum... you want... decimal sum = ++due; That should fix it.

      Matthew Butler

      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