﻿ VB Helper: HowTo: Calculate the future value of a monthly investment with interest in Visual Basic .NET     Home Search   What's New Index Books Links Q & A Newsletter Banners   Feedback Tip Jar       MSDN Visual Basic Community  Title Calculate the future value of a monthly investment with interest in Visual Basic .NET This example shows how to calculate the future value of a monthly investment with interest in Visual Basic .NET. algorithms, mathematics, finance, interest, monthly investment, investment, example, example program, Windows Forms programming, Visual Basic .NET, VB.NET Algorithms The magic of compound interest is that, over time, you get interest on the interest

For each month the program calculates the interest on the account balance. It then adds the interest and a monthly contribution to the balance and displays the result. (Note that interest is compounded monthly not continuously.)

The following code shows how the program performs its calculations.

```' Calculate the interest compounded monthly.
Private Sub btnGo_Click(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles btnGo.Click
' Get the parameters.
Dim monthly_contribution As Decimal = Decimal.Parse( _
txtMonthlyContribution.Text, NumberStyles.Any)
Dim num_months As Integer = _
Integer.Parse(txtNumMonths.Text)
Dim interest_rate As Decimal = Decimal.Parse( _
txtInterestRate.Text.Replace("%", "")) / 100
interest_rate /= 12

' Calculate.
lvwBalance.Items.Clear()
Dim balance As Decimal = 0
For i As Integer = 1 To num_months
' Display the month.
Dim new_item As ListViewItem = _

' Display the interest.
Dim interest As Decimal = balance * interest_rate

balance += monthly_contribution

' Display the balance.
balance += interest  Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.  Updated 