﻿ VB Helper: HowTo: Calculate the future value of a monthly investment with interest in Visual Basic 6     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 6 This example shows how to calculate the future value of a monthly investment with interest in Visual Basic 6. algorithms, mathematics, finance, interest, monthly investment, investment, example, example program, Windows Forms programming, Visual Basic 6, VB 6 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 cmdGo_Click()
Dim monthly_contribution As Double
Dim num_months As Integer
Dim interest_rate As Double
Dim balance As Double
Dim i As Integer
Dim new_item As ListItem
Dim interest As Double

' Get the parameters.
monthly_contribution = _
ParseCurrency(txtMonthlyContribution.Text)
num_months = Val(txtNumMonths.Text)
interest_rate = ParsePercent(txtInterestRate.Text) / 12

' Calculate.
lvwBalance.ListItems.Clear
balance = 0
For i = 1 To num_months
' Display the month.
Set new_item = _

' Display the interest.
interest = balance * interest_rate
Text:=FormatCurrency\$(interest)

balance = balance + monthly_contribution

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