Hello All,
I have been given an assignment in my VB crash course and I'm stuck on the Financial.Pmt method. The program is a loan calculator that has the user input the total amout of the loan, interest rate, and term in years. The program should then display the "total" overall interest to be paid and the total amount to be repaid. I think I am stuck on the Financial.PMT method.
Any help is greatly appreciated. I have my code shown below.
CODE
' Project name: Quick loans calculator
' Project purpose: The project allows a user to enter a loan amount, interest rate,
' and term. The project calculates and displays,
' the total amount of interest and the total amount to be repaid
Option Explicit On
Option Strict Off
Imports System.Globalization
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub exitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click
Me.Close()
End Sub
Private Sub calcButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calcButton.Click
' calculates the total interest and total amout to be repaid
' declare constants and variables
Dim Rate As Decimal
Dim Term As Decimal
Dim PV As Decimal
Dim totalInterest As Decimal
Dim totalAmount As Decimal
Dim monthlyPayment As Decimal
Dim isconverted As Boolean
' setting values to each variable
Rate = interestTextBox.Text
Term = termTextBox.Text
PV = amountTextBox.Text
' convert input to numbers
isconverted = Decimal.TryParse(amountTextBox.Text, NumberStyles.Currency, NumberFormatInfo.CurrentInfo, PV)
isconverted = Decimal.TryParse(interestTextBox.Text, NumberStyles.Currency, NumberFormatInfo.CurrentInfo, Rate)
isconverted = Decimal.TryParse(termTextBox.Text, NumberStyles.Currency, NumberFormatInfo.CurrentInfo, Term)
monthlyPayment = Convert.ToDecimal(-Financial.Pmt(Rate / 12, Term * 12, PV))
'totalInterest = PV * Rate * Term
interestLabel.Text = Convert.ToString(totalInterest)
totalLabel.Text = Convert.ToString(totalAmount)
End Sub
End Class