Hi! I am supposed to create a program that will display an investment schedule in a list box for my Visual Basics Class.
1. It says that annual interest is calculated using the simple interest formula:
Interest = (Beginning Balance + Annual Investment) * Rate
Assume the Investment Rate is entered and displayed as an annual rate. This formula also assumes the annual investment is made at the beginning of each year.
2. Include column headings and format numeric data appropriately.
3. This project can be completed using Do While or Do Until loop.
My Instructor gave me a paper of what the list box should display if done correctly, but I can't seem to get it right.
So I really need some help. I would really appriciate it.
Given: Annual Investment Amount = 1000
Investment Rate = 5.500
Future Value = 10000
This is what I have so far, So I would again appriciate it if you could help me with my error. Thanks
Option Strict On
Public Class Form1
Private Sub btnDisplaySch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplaySch.Click
Dim EditMask, OutString As String
Dim Year As Integer
Dim AnnIA, InvestR, FutureVal, BegBal, Interest, EndBal As Double
AnnIA = numAnnIA.Value
InvestR = numInvestR.Value
FutureVal = numFutureVal.Value
EditMask = "{0,5:N0} {1,12:N2} {2,12:N2} {3,12:N2} {4,12:N2}"
' Print Headings
lstResults.Items.Clear()
OutString = String.Format(EditMask, " ", "Beginning", "Annual", " ", "Ending")
lstResults.Items.Add(OutString)
OutString = String.Format(EditMask, "Year", "Balance", "Investment", "Interest", "Balance")
lstResults.Items.Add(OutString)
EndBal = 0
Year = 0
Do While EndBal < FutureVal
Year += 1
BegBal = AnnIA
Interest = (BegBal + AnnIA) * InvestR
Interest = Math.Round(Interest, 2)
If EndBal > FutureVal Then
End If
EndBal = BegBal + Interest + AnnIA
OutString = String.Format(EditMask, Year, BegBal, AnnIA, Interest, EndBal)
lstResults.Items.Add(OutString)
Loop
End Sub