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.
PV# Function Example
◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
' This example uses the PV# function to return the present value of an
' annuity.
' Note: To run this example you must use the FINANCE.QLB Quick library.
' The FINANCE.BI include file must also be present.
' To try this example:
' 1. Choose New Project from the File menu
' 2. Copy the code example below to the code window
' 3. Press F5 to run the example
' $INCLUDE: 'FINANCE.BI'
CONST ENDPERIOD = 0
CONST BEGINPERIOD = 1
CONST DOLLARFORMAT$ = "$#,###,##0.00"
DEFDBL A-Z
DIM APR AS SINGLE
DIM Status AS INTEGER
APR = .102
Period = 20
YearlyIncome = 50000
FutureValue = 1000000
' Explain the premise
CLS
PRINT "It seems you've won a million dollar lottery and you're going to"
PRINT "get $50,000.00 each year for the next 20 years."
PRINT
PRINT "You're curious about how much it's actually costing the people who"
PRINT "run the lottery to pay you that $1,000,000.00 over 20 years."
PRINT
PRINT "Assume the prevailing interest rate is 10.2% compounded annually."
PRINT
' Calculate the present value of an annuity.
PresentValue = PV#(APR, 20, -YearlyIncome, FutureValue, BEGINPERIOD, Status)
' Examine Status to determine success or failure of PV#
IF Status THEN
' If unsuccessful, announce a problem.
PRINT "There was an error in calculating the present value of an _"
annuity. ""
ELSE
' If successful, display the results.
PresentValue$ = FORMAT$(PresentValue, DOLLARFORMAT$)
PRINT "Calculations show that the lottery people only have to deposit ";
PRINT PresentValue$; ""
PRINT "to ensure that you get your money."
END IF