The Financial control provides methods used to perform complicated financial calculations. Before you can work with a Financial control, you must create it at run time. If you also add a reference to the control in the References dialog box, Visual Basic offers suggestions on using the method syntax. For more complete documentation and examples, see the Visual Basic 6.0 Help for the financial functions.
The financial methods all return a double-precision number that represents the result of the financial calculation. The results of the calculation are based on the parameters passed to the method, so it is important to use correct parameter values.
The parameters representing rates and times such as life, period, rate, per, and nper must all use the same time period in each call to the method. For example, if you specify life in months, you also must specify period in months. As another example, if you calculate rate using months, you also must calculate nper using months.
Parameters that express percentage figures such as rate, finance_rate, and reinvest_rate generally are represented in decimal notation. For example, 10 percent is represented as 0.10.
For all parameters, negative numbers usually represent cash paid out, such as deposits to savings, and positive numbers represent cash received, such as dividend checks. For example, the value parameter uses a Variant array specifying cash flow values. The array passed to value must contain at least one negative value (a payment) and one positive value (a receipt).
The following code example shows how to use the financial control to calculate the number of payments on a car loan using the NPer method. The NPer method calculates the number of $500 payments needed to pay back a $12,000 loan with an annual interest rate of 10 percent.
Private Sub CalcPayments_Click()
Dim FF As pVBFinFunc
Dim rate, pmt, pv, payments
'The interest rate is 10% annually
'Payments are monthly, so rate is divided by 12
rate = 0.1 / 12
'pmt is the amount paid each month
pmt = -500
'pv is the present value of the loan to the lender
pv = 12000
'Create the Financial control
Set FF = CreateObject("pvbfinfunc.pvbfinfunc")
'Calculate the number of monthly payments
payments = FF.NPer(rate, pmt, pv)
'Convert the number of payments to a whole number
'The last payment may be less than $500
payments = Int(payments) + 1
'Release the control
Set FF = Nothing
End Sub
As the code example demonstrates, you must calculate the values for the parameters in order to use the NPer method. The first parameter is rate. Since the payment is made once per month, or 12 times per year, divide the annual interest rate by 12 to get rate. In this case rate is 0.10 / 12, or approximately 0.0083.
The next parameter is pmt. The pmt parameter and the rate parameter must use the same period. In this case, pmt is expressed in months, as $500 per month. Since it is a payment, it is expressed as a negative number, –500.
The final parameter to specify is pv, the present value of the loan. For example, when you borrow money to buy a car, the loan amount is the present value to the lender of the monthly car payments you will make. In this example, pv is $12,000.
The optional parameters fv and type are not used in this example. The fv parameter is used for specifying future value or the cash balance you want after you have made the final payment. For example, the future value of a loan is $0 because that is its value after the final payment. However, if you want to save $50,000 over 18 years for your child's education, then $50,000 is the future value. Since fv is omitted, 0 is assumed. The type parameter determines whether the payment is made at the beginning or end of the payment period. Since type is omitted, the value is 0 by default.