ex.hlp (Topic list)
Rate# Function 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 the FINANCE.QLB Quick library. The
' FINANCE.BI include file must also be present.
 
' $INCLUDE: 'FINANCE.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                             ' Clear the screen
 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$ = FORMAT$(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