Example of NPV and IRR Financial Functions in VB for WindowsLast reviewed: June 21, 1995Article ID: Q110888 |
The information in this article applies to:
- Professional Edition of Microsoft Visual Basic programming system for Windows, version 3.0
SUMMARYThis article explains the NPV and IRR financial functions and gives a sample program.
MORE INFORMATIONThe NPV, IRR, and MIRR functions are used for investments that are a series of nonconstant cash payments made at equal intervals. You pass the series of nonconstant payments in an array. The nonconstant-payment functions (NPV, IRR, and MIRR) are in a different category than the financial functions for annuity investments (FV, IPmt, Rate, NPer, PV, Pmt, and PPmt). In an annuity, each cash payment is the same constant amount, made at equal intervals. The present value (PV) of a future cash receipt is the amount of money that, if received today, would be considered equivalent to the future receipt, at a given interest rate. The present value is less than the future receipt because you can earn interest on money received today. NPV (Net Present Value) compares (subtracts) the current value of a series of future cash flows with an amount invested today. NPV is useful to compare investment opportunities at a given discount (interest) rate. The discount rate (found with the Rate function) can be viewed as the rate of return you want out of your investment. If NPV is greater than or equal to 0, the investment equals or exceeds your interest (discount) rate requirement; if NPV is less than 0, the investment does not meet your interest rate requirement. The IRR function returns Internal Rate of Return. IRR returns the discount rate at which NPV would return 0 (zero). For a given array of cash flow values, IRR can be thought of as an average interest rate (which compounds at each period). If IRR is lower than the interest rate you desire for this investment, then it is not a good investment. The first element of the input cash-flow array should usually be negative, indicating your initial investment. A high (positive) income early in the value array will make IRR higher than if the same high income instead occurred later in the array. This is an example of the time value of money. Please refer to an Accounting textbook for more information about these standard Accounting functions.
Step-by-Step Example with Code
NOTE: By definition, IRR returns the discount rate at which NPV returns 0.
NPV, IRR, MIRR: Reference to Undefined Function or ArrayFor more information, see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q101245 TITLE : BUG: Ref to NPV / IRR / MIRR Gives Undefined Functions ErrorIf you try to run an application that contains a reference to the NPV, IRR, or MIRR financial function, Visual Basic for Windows generates this error:
Reference to undefined Function or ArrayVisual Basic does not recognized these as Visual Basic functions because they were incorrectly referenced in the financial DLL file (MSAFINX.DLL) that ships with Visual Basic version 3.0. To work around the problem, you can declare the NPVC, IRRC, and MIRRC functions located in MSAFINX.DLL and alias them as NPV, IRR, and MIRR respectively, as shown farther above.
|
Additional reference words: 3.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |