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. row addition

row addition

Scheduled Pinned Locked Moved Visual Basic
question
4 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
    Makniteasy
    wrote on last edited by
    #1

    I have a datagrid with 6 columns. column 6 is the balance column and column 4 is the amount payed.I need column4 row1 to subtract from column6 row1 and show in row2 column6.then I need column4 row2 to subtract from column6 row2 and show in column6 row3. I need this to loop or something. any suggestions?

    B 1 Reply Last reply
    0
    • M Makniteasy

      I have a datagrid with 6 columns. column 6 is the balance column and column 4 is the amount payed.I need column4 row1 to subtract from column6 row1 and show in row2 column6.then I need column4 row2 to subtract from column6 row2 and show in column6 row3. I need this to loop or something. any suggestions?

      B Offline
      B Offline
      Briga
      wrote on last edited by
      #2

      Not sure if that is what you need but sounds like: for index=1 to datagrid.count-1 datagrid.rows(index).item("Column6")=datagrid.rows(index-1).item("Column6")-datagrid.rows(index).item("Column4") next index Briga

      M 1 Reply Last reply
      0
      • B Briga

        Not sure if that is what you need but sounds like: for index=1 to datagrid.count-1 datagrid.rows(index).item("Column6")=datagrid.rows(index-1).item("Column6")-datagrid.rows(index).item("Column4") next index Briga

        M Offline
        M Offline
        Makniteasy
        wrote on last edited by
        #3

        ummm... I dont understand why count is underlined as wrong and datagrid.rows is wrong?? any suggestions? thanx

        B 1 Reply Last reply
        0
        • M Makniteasy

          ummm... I dont understand why count is underlined as wrong and datagrid.rows is wrong?? any suggestions? thanx

          B Offline
          B Offline
          Briga
          wrote on last edited by
          #4

          Well I replied quickly and typed the code just to give you the idea. The error you get is because the count and rows should refer the realdatabase you have behing the datagrid (dataset or dataview or whatever). Since I don't know the architecure of your application I don't konw how to address it but you can easily transpose the following code: Let's suppose you have a dataset called d1 with a table t1 with two columns: c1 & c2. Where c2 is the progressive total as you want. You can create a sub passing the table, the index of the value column and the index of the progressive total column as follows: private sub RecalcProgressive(dt as datatable,i1 as integer,i2 as integer) dim index as integer ' if dt.rows.count=0 then exit sub ' If no records then exit dt.rows(0).item(i2)=dt.rows(0).item(i1) ' First line only progressive=value if dt.rows.count=1 then exit sub ' If only one line then it's done for index=1 to dt.rows.count-1 ' For each line in the DB dt.rows(index).item(i2)=dt.rows(index).item(i1)+dt.rows(index-1).item(i2) ' Calc next index end sub Then, according to the hypothesis before, you can call it: public sub Main <...> RecalcProgressive(d1.t1,1,2) <...> end sub Bye Briga

          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