Saturday, April 4, 2015

Loan Interest Solver in Visual Basic 6

Most of us experiencing some financial problems in our lives we need to borrow money to support ourselves and our family. We cannot deny the reality in life that it is not easy to earn money for a living especially our economy is not stable enough to provide most people secure jobs to have a steady income.  When we make a loan from a bank, financial institution like a lending company or individual person the money that we loan has a interest for them to earn their money in return. That is called investment of their money in business stand of point. There are several agreements that the lender and the creditor can be agree for example let say a person would like to loan of an amount of $2000 the interest rate that is being agreed by both parties including the lender and the creditor is 10% per month interest rate payable for within two months for example.  That will be $200 dollars per month for two months it will be $400 to the total amount to be paid per month is $1200 for two months the total amount that is due is $2400. This computation is very simple is we are dealing only with monthly payment for a small amount.

How about if the loan is big amount let say $10,000 with 5% interest per year  or annum and payable for 10 years with compounded interest penalty rate if the payment was not able to be paid within the set payment schedule? What is the correct formula to derive to the solution to the problem to answer this question I created a program in Microsoft Visual Basic 6 I called this program Loan Compound Interest Solver.  This program will help the creditor and its customer compute the interest amount to be paid per year depending to the amount to be loaned, the interest rate that is being agree and the number of years the amount to be paid to the creditor or lender of the money.

I make the program very easy to use and does not use complicated programming codes to compute the interest rate of the amount to be paid. The first step that we do is the creation of the graphical user interface that will interact to the end user of our program. In this case we have a first label that will ask the user what is the principal amount to be loaned the value is being stored in a textbox we named the textbox txtAmount.text.  The second label we are the user to enter the interest rate we store the value in a textbox named txtInterest.txt  in this case we use numerical value rather than putting a number with a percentage symbol to avoid confusion on the part of our end user. The third label our program will ask again the user now many years to be paid in this portion every year there is a computation that is being performed by our program to get the amount that should be paid by the customer to its creditor for example a bank or any financial institution the variable that we will use for the storage of the years to be paid will be store in txtYears.txt.

After these values is being provided by the end user of our program the next step is for the user to press or click the compute button to perform a series of computation that shows the amount to be paid every year and the amount including its interest in our list box.  When the values is being listed in our list box the user has the option to clear the values by selecting the clear button it will erase all the contents of computation in the list box and the values in the text box so that the user can put a new set of values to be computed by our program. If the user is done all the computation the user is given a chance to quit the program by pressing the quit button. This quit button will display a confirmation dialog box that asking the user if the user is really sure to quit the program or not.  

Below is the complete program listing of our Loan Compounded Interest Solver.


Option Explicit

Private Sub cmd_compute_Click()
 Dim years, years2 As Integer
              Dim Interest_Rate_Value As Double
Dim Amount_Loaned As Currency
Dim Principal_Amount As Currency
lstdisplayvalues.Clear
years = Val(txtYears.Text)
Principal_Amount = Val(txtAmount.Text)

Interest_Rate_Value = (Val(txtInterest.Text) / 100)

lstdisplayvalues.AddItem vbTab & " Year " & vbTab & " Amount On Deposit "

For years2 = 1 To years

                Amount_Loaned = Principal_Amount * (1 + Interest_Rate_Value) ^ years2
 lstdisplayvalues.AddItem vbTab & Format$(years2, "@@@@") & vbTab & _
                          Format$(Format$(Amount_Loaned, "Currency"), _
                          String$(17, "@"))
 Next years2
End Sub

Private Sub cmd_quit_Click()
Dim reply As String
reply = MsgBox("Do you want to quit program?", vbYesNo + vbQuestion + vbDefaultButton2, "Quit Program")
If (reply = vbYes) Then
  Unload Me
  Else
  frmloan.Show
                 frmloan.txtAmount.SetFocus
                End If
End Sub

Private Sub cmdclear_Click()
txtAmount.Text = ""
txtInterest.Text = ""
txtYears.Text = ""
lstdisplayvalues.Clear
txtAmount.SetFocus
End Sub

This program is not complicated but simple enough that everyone that is interested how to write a loan compounded interest solver program will have a good idea how to start from int. If you want to improve your skills and knowledge in programming always write in a piece of paper what is the desired output of the program, what are the important requirements before you can write a single line of code. By doing this you can more focusing on solving the problem because you have already a clear picture on how the program will be developed and implement.  Good planning means faster the implementation of the project specially in software development.  If you have some questions, comments and suggestions feel free to contact me I am eager to answer your queries about this matter.


Thank you very much and Happy Productive Programming Everyone.





Sample Program Output



No comments:

Post a Comment