bas7ex.hlp (Topic list)
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.
Rate# Function Programming Example
                       Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
'This example uses the Rate# function to determine the interest rate
'of a loan.
 
'Note: To run this example you must use a Quick library that includes
'the procedures contained in the date/time/format and financial function
'library files. The following include files must also be present.
 
'$INCLUDE: 'FINANC.BI'
'$INCLUDE: 'FORMAT.BI'
 
CONST ENDPER = 0
CONST BEGINPER = 1
CONST PERCENT$ = "#0.0"
DEFDBL A-Z
DIM Status AS INTEGER
 
PresVal = 8000
Pmnt = 200
Guess = .5
 
'Explain the premise.
CLS
PRINT "Your brother-in-law says he'll loan you $8000.00 if you agree to"
PRINT "repay the loan over the next 4 years at $200.00 a month. What he"
PRINT "doesn't tell you is the interest rate he's charging. Banks will "
PRINT "charge you at least 12% a year. You need to know what your"
PRINT "brother-in-law's interest rate is so you can get the best deal."
PRINT
 
'Calculate the interest rate.
IntRate = (Rate#(48, -Pmnt, PresVal, 0, BEGINPER, Guess, Status) * 12) * 100
 
'Examine Status to determine success or failure of Rate#.
IF Status THEN
    'If unsuccessful, announce a problem.
    PRINT "There was an error in calculating the interest rate."
ELSE
    'If successful format and display the results.
    IntRate$ = FormatD$(IntRate, PERCENT$)
    PRINT "Calculations show that your brother-in-law is only going to"
    PRINT "charge you "; IntRate$; "% per year. Sounds like a nice guy."
END IF