row addition
-
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?
-
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?
-
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
ummm... I dont understand why count is underlined as wrong and datagrid.rows is wrong?? any suggestions? thanx
-
ummm... I dont understand why count is underlined as wrong and datagrid.rows is wrong?? any suggestions? thanx
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