goldfingerpunk
asked on
Help with code for interest calculation formula visual basic 2008
Im having problems with getting the correct formula for this assignment. I did what the book says and its not working. I have to enter a principal and then in the multiline text box I have to have one column with the rate(%) which are 5,6,7,8,9 and 10 and then the other column has to be the amount after 10 years. It says the interest calculation formula is a=p(1+r)^n. This is what I got so far and nothing is appearing in my multiline text box.
Private Sub calculateButton_Click(ByVa l sender As System.Object, ByVal e As System.EventArgs) Handles calculateButton.Click
' Declare Variables
Dim Principal As Decimal
Dim Rate As Double
Dim Amount As Decimal
Dim Output As String
' Retrieve User Input
Principal = Val(principalTextBox.Text)
Output = ResultTextBox.Text
' Set Output Header
Output = "Rate(%)" & ControlChars.Tab & ControlChars.Tab & "Amount after 10 years" & ControlChars.CrLf
' Calculate Amount
For years As Integer = 5 To 10
Amount = _
Principal * ((1 + Rate) ^ 10)
Output = ("5" & ControlChars.Tab & ControlChars.Tab & _
String.Format("{0:C}", Amount) & ControlChars.CrLf)
Next
End Sub
Any help please im getting frustrated.
Private Sub calculateButton_Click(ByVa
' Declare Variables
Dim Principal As Decimal
Dim Rate As Double
Dim Amount As Decimal
Dim Output As String
' Retrieve User Input
Principal = Val(principalTextBox.Text)
Output = ResultTextBox.Text
' Set Output Header
Output = "Rate(%)" & ControlChars.Tab & ControlChars.Tab & "Amount after 10 years" & ControlChars.CrLf
' Calculate Amount
For years As Integer = 5 To 10
Amount = _
Principal * ((1 + Rate) ^ 10)
Output = ("5" & ControlChars.Tab & ControlChars.Tab & _
String.Format("{0:C}", Amount) & ControlChars.CrLf)
Next
End Sub
Any help please im getting frustrated.
ASKER
It calculated but now the problem is it has one column of all 5's and the other column is the same number too
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window