Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
NPer# Function Programming Example
◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
'This example uses the NPer# function to determine how many periods, or
'payments, must be made to pay off a loan.
'Note: To run this example you must use a Quick library that includes the
'procedures contained in the financial function library files. The
'following include files must also be present.
'$INCLUDE: 'FINANC.BI'
CONST ENDPER = 0
CONST BEGINPER = 1
DEFDBL A-Z
DIM APR AS SINGLE
DIM Status AS INTEGER
PresVal = 8000
FutrVal = 0
Payment = 250
APR = .102
'Explain the premise.
CLS
PRINT "You're trying to buy a new car that costs $8000.00. Your budget"
PRINT "only allows you to spend up to $250.00 per month to buy the car"
PRINT "and you don't have a down payment."
PRINT
PRINT "Car loans are normally financed for 12, 24, 36 or 48 months. You'd"
PRINT "like to figure out how long you must finance to stay within your"
PRINT "budget."
PRINT
Periods = NPer#(APR / 12, -Payment, PresVal, FutrVal, BEGINPER, Status)
'Examine Status to determine success of failure of NPer#.
IF Status THEN
'If unsuccessful, announce a problem.
PRINT "There was an error in calculating the number of periods"
PRINT "in your loan."
ELSE
'If successful, display the results.
PRINT "Calculations reveal that at exactly $250.00 per month"
PRINT "you would have to finance for at least"; INT(Periods); "months."
PRINT
PRINT "It appears that you'll have to finance for 48 months unless you"
PRINT "can come up with a $210.00 downpayment."
END IF