Cumulative Addition using GRID Control

Quote:

> >I am trying to do some cumulative addition of some numbers

> >so the formula is B1= A1 (only true for B1)

> >For all other values in ColumnB the formula is for example

> >Bn = An +B(n-1)

> Then do it like this:

> For i% = Grid.FixedRows To Grid.Rows - 1 ' We start on .FixedRows to

> ' exclude fixed rows from

> ' processing

> Grid.Row = i%

> Grid.Col = Grid.FixedCols

> ' Since OldB = 0 when we're at the first row, both formulas are used.

> A = Val(Grid.Text)

> B = A + OldB

> OldB = B

> Grid.Col = Grid.FixedCols + 1

> Grid.Text = CStr(B)

> Next i%

> --

> Sex isn't the answer. Sex is the question. Yes! is the answer

First of all, for future reference please post VB queries in the Visual

Basic groups.

Secondly, why are you using so many variables when you could just do

this:

Dim FinalValue% 'Are you sure this is an integer?

For i%=1 to Grid.FixedRows

Grid.Row=i%

FinalValue%=FinalValue%+Val(Grid.Text)

Next i%

Or, I'm sure you could use the formula property or something like that.

--

secret face of God." | http://www.nauticom.net/~jfarr

- G. K. Chesterton | Dept. of Redundancy Dept.