Financial Class
Assembly: Microsoft.VisualBasic (in microsoft.visualbasic.dll)
For more detailed information, see the Visual Basic topic Financial Module (Visual Basic).
This module supports the Visual Basic run-time library members that perform financial calculations such as depreciation, present and future values, interest rates, rates of return, and payments.
This example uses the Rate function to calculate the interest rate of a loan, given the total number of payments (TotPmts), the amount of the loan payment (Payment), the present value or principal of the loan (PVal), the future value of the loan (FVal), a number that indicates whether the payment is due at the beginning or end of the payment period (PayType), and an approximation of the expected interest rate (Guess).
Sub TestRate() Dim PVal, Payment, TotPmts, APR As Double Dim PayType As DueDate ' Define percentage format. Dim Fmt As String = "##0.00" Dim Response As MsgBoxResult ' Usually 0 for a loan. Dim FVal As Double = 0 ' Guess of 10 percent. Dim Guess As Double = 0.1 PVal = CDbl(InputBox("How much did you borrow?")) Payment = CDbl(InputBox("What's your monthly payment?")) TotPmts = CDbl(InputBox("How many monthly payments do you have to make?")) Response = MsgBox("Do you make payments at the end of the month?", MsgBoxStyle.YesNo) If Response = MsgBoxResult.No Then PayType = DueDate.BegOfPeriod Else PayType = DueDate.EndOfPeriod End If APR = (Rate(TotPmts, -Payment, PVal, FVal, PayType, Guess) * 12) * 100 MsgBox("Your interest rate is " & Format(CInt(APR), Fmt) & " percent.") End Sub
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.