How to Compute a Subtotal While Data Is Being Entered
ID: Q106694
The information in this article applies to:
- Microsoft FoxPro for Windows, versions 2.5, 2.5a, and 2.5b
- Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a, and 2.5b
SUMMARY
The sample code below computes a sum of numbers and displays the total
while the data is being entered. SUBTOTAL must add all the numbers together
before displaying the subtotal.
MORE INFORMATION
CLEAR
SET TALK OFF
PUBLIC N1,N2,N3
STORE 0 TO N1,N2,N3
STORE 15 TO X
@7,12 SAY "N1: " GET N1 VALID SUBTOTAL() PICTURE "9,999.99"
@8,12 SAY "N2: " GET N2 VALID SUBTOTAL() PICTURE "9,999.99"
@9,12 SAY "N3: " GET N3 VALID SUBTOTAL() PICTURE "9,999.99"
READ
RETURN
**********************************************************
* FUNCTION: SUBTOTAL
* NOTES... This function computes a sum of numbers and
* displays the total while the data is being
* entered.
* PARAMETERS: NONE. However, the numbers to be summed and
* the row and column values must be declared
* public.
**********************************************************
FUNCTION SUBTOTAL
STOTAL=N1+N2+N3
@X,4 SAY "subtotal: "
@X,COL() SAY STOTAL PICTURE "99,999.99"
RETURN(.T.)
Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a 2.50b
KBCategory: kbprg kbcode
KBSubcategory: FxprgGeneral
|