' Interest.vb
' Calculating compound interest.

    Imports System.Windows.Forms

Module modInterest

    Sub Main()

        Dim amount, principal As Decimal ' dollar amounts
        Dim rate As Double              ' interest rate
        Dim year As Integer              ' year counter
        Dim output As String            ' amount after each year

        principal = 1000.0
        rate = 0.05

        output = "Year" & vbTab & "Amount on deposit" & vbCrLf

        ' calculate amount after each year
        For year = 1 To 10
            amount = principal * (1 + rate) ^ year
            output &= year & vbTab & _
               String.Format("{0:C}", amount) & vbCrLf
        Next

        ' display output
        MessageBox.Show(output, "Compound Interest", _
           MessageBoxButtons.Ok, MessageBoxIcon.Information)

    End Sub ' Main

End Module ' modInterest

