Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculation in grid AfterRowColChange event
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00696537
Message ID:
00696717
Views:
14
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
>
>
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform