help with interest formula

Michael_85

Member
Joined
Mar 15, 2009
Messages
9
Programming Experience
Beginner
Hi Have project that i am working on and just hit a brick wall can't figure out where i am going wrong little help please


I have been Give this formual

A= P * (1 + r/100) ^ T

P Is the Principal
R Is the Annual Rate Of Interest
T Is the period of investment in years
A Is the amount that the principal becomes after T years


When i add compound interest and principal together it says it = £5100 Which can't be right

A= P * (1 + r/100) ^ T

P Is the Principal
R Is the Annual Rate Of Interest
T Is the period of investment in years
A Is the amount that the principal becomes after T years

when it output the compound interest no matter what value i put in in it still say compund interest = £100
also
When i add compund interest and principal together it says it = £5100 Which can't be right
VB.NET:
Public Class frmCompound

    Private Sub lblCalCompound_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblCalCompound.Click
        Dim intValAmount, intCompoundInterest, intValYears, intFristInterest As Integer
        Dim RateOfInterest As Double
        'test for blank value
        If Me.txtAmountCompound.Text = "" Then
            'Output an error message
            MessageBox.Show("You must enter a value!", "Invalid input")
            Me.txtAmountCompound.Focus()
        Else
            'Test that entry is a number 
            If Not IsNumeric(txtAmountCompound.Text) Then
                MessageBox.Show(" Your amount of investment entry is not a number")
            Else
                ' Test that Amount is More £100
                If Val(txtAmountCompound.Text) < 100 Then
                    'Output an error message
                    MessageBox.Show("Enter A Value higher That £99")
                Else
                    intValAmount = Val(txtAmountCompound.Text)
                End If
            End If
        End If

        If Me.txtPeriodCompound.Text = "" Then
            'Output an error message
            MessageBox.Show("You must enter a value!", "Invalid input")
            Me.txtAmountCompound.Focus()
        Else
            ' Test That entry is a number
            If Not IsNumeric(txtPeriodCompound.Text) Then
                'Output an error message
                MessageBox.Show(" Your period of investment entry is not a number")
                Me.txtAmountOfInterestCompound.Text = ""
                'Output an error message
                MessageBox.Show("You must enter a value!", "Invalid input")
                Me.txtAmountOfInterestCompound.Focus()
            Else
                intValYears = Val(txtPeriodCompound.Text)
            End If
        End If

        'Test That entry is a number
        If Not IsNumeric(txtAmountOfInterestCompound.Text) Then
            'Output an error message
            MessageBox.Show(" Your rate of interest entry is not a number")
        Else
            RateOfInterest = Val(txtAmountOfInterestCompound.Text)
        End If

        intFristInterest = intValAmount * (1 + RateOfInterest / 100) ^ intValYears
        intCompoundInterest = intFristInterest - intValAmount
        'Output Simple ineterest earned
        MessageBox.Show(" The compound interest is £ " & CStr(intCompoundInterest) & MessageBoxButtons.OK)
        'Output total simple interest earned and amount invested add together
        MessageBox.Show(" The compund interest and Principal is £ " & CStr(intCompoundInterest + intValAmount) & MessageBoxButtons.OK)

    End Sub
 
Last edited:
Hello.

Just a short question, is it:
VB.NET:
A = (P * (1 + r/100)) ^ T
or
VB.NET:
A= P * ((1 + r/100) ^ T)
?

Also you should consider using NumericUpDowns instead of Textboxes and drop the 'old' VB6 conversions in favor for the Convert class and the ToString() method.

Bobby
 
Back
Top