Hi,
I am fairly new to this and I am trying to create a form that will calculate compound interest. [FONT="]To encourage the user to invest more money for longer periods, also display the consequences if the investment were for twice and three times the amount and years. [/FONT]I have attached the form. I believe I need to use a For ... Next Loop, but I need some help executing code. Please Help. Thanks
Example:
Total to invest: 1000
Number of years: 5
Interest Rate 7.5
Calculate Earnings (button)
Answer (label): $1453.00
This is the code I have so far.
Private Sub cmdCalculate_Click()
Dim intAmount As Currency, intYear As Integer, intRate As Integer, varAmount As Currency
intAmount = Val(Me.txtAmount)
intYear = Val(Me.txtYear)
intRate = Val(Me.txtRate)
varAmount = txtAmount + (txtAmount * (txtRate / 100 / 12))
Dim intI As Currency
For intI = varAmount To (txtYear) * 12
Next intI
Me.lblTotal.Caption = "At the end of " & txtYear & " years" & vbCrLf _
& "the total savings will be " & intI
Me.lblTotal2.Caption = "If you invest " & txtAmount & " for " & txtYear * 2 & " years" & vbCrLf _
& "the total savings will be " & intI
Me.lblTotal3.Caption = "If you invest " & txtAmount & " for " & txtYear * 3 & " years" & vbCrLf _
& "the total savings will be " & intI
End Sub
I am fairly new to this and I am trying to create a form that will calculate compound interest. [FONT="]To encourage the user to invest more money for longer periods, also display the consequences if the investment were for twice and three times the amount and years. [/FONT]I have attached the form. I believe I need to use a For ... Next Loop, but I need some help executing code. Please Help. Thanks
Example:
Total to invest: 1000
Number of years: 5
Interest Rate 7.5
Calculate Earnings (button)
Answer (label): $1453.00
This is the code I have so far.
Private Sub cmdCalculate_Click()
Dim intAmount As Currency, intYear As Integer, intRate As Integer, varAmount As Currency
intAmount = Val(Me.txtAmount)
intYear = Val(Me.txtYear)
intRate = Val(Me.txtRate)
varAmount = txtAmount + (txtAmount * (txtRate / 100 / 12))
Dim intI As Currency
For intI = varAmount To (txtYear) * 12
Next intI
Me.lblTotal.Caption = "At the end of " & txtYear & " years" & vbCrLf _
& "the total savings will be " & intI
Me.lblTotal2.Caption = "If you invest " & txtAmount & " for " & txtYear * 2 & " years" & vbCrLf _
& "the total savings will be " & intI
Me.lblTotal3.Caption = "If you invest " & txtAmount & " for " & txtYear * 3 & " years" & vbCrLf _
& "the total savings will be " & intI
End Sub
Attachments
Last edited: