Jayesh,
Since this is an
O(n2) algorithm I wouldn't recommend using it for anything but very small numbers of rows.
O(n2) algorithms are very, very bad.
>2. Create new form method and call it Calculate.
>
>3. Drop a Grid on the form with 3 Columns. Last Column should have Thisform.Calculate() as Controlsource.
>
>4. Put the following code into Calculate method.
>
>
>
>LPARAMETERS tnRecNo
>
>LOCAL lnRecNo,lnRtnValue
>
>lnRtnValue = 0
>lnRecNo = RECNO("c1") - 1
>
>IF lnRecNo >= 1
> SELECT C2
> SUM C2.cB FOR RECNO() <= lnRecNo TO lnRtnValue
> lnRtnValue = lnRtnValue + C1.cB
>ELSE
> lnRtnValue = C1.cB
>ENDIF
>
>SELECT C1
>RETURN lnRtnValue
>
>