Review http://www.vb-helper.com/howto_calculate_interest.html
Code:
If IsNull(Me.txtAmount) Or IsNull(Me.txtYears) Or IsNull(Me.txtInterest) Then
MsgBox "Please supply data required.", vbCritical, "Data Needed"
'warn user and exit sub
ElseIf Val(Me.txtAmount) = 0 Then
MsgBox "All values entered should be above 0.", vbCritical, "Data Correction"
Me.txtAmount = Null
ElseIf Val(Me.txtInterest) = 0 Then
MsgBox "All values entered should be above 0.", vbCritical, "Data Correction"
Me.txtAmount = Null
ElseIf Val(Me.txtYears) = 0 Then
MsgBox "All values entered should be above 0.", vbCritical, "Data Correction"
Me.txtAmount = Null
Else
Dim intI As Integer, intCounter As Integer, sngTotal4 As Integer, intYears As Integer, sngInterest As Single, sngTotal As Single, sngTotal3 As Single, sngTotal2 As Single
sngTotal = Val(Me.txtAmount)
sngInterest = Val(Me.txtInterest) / 100
intYears = Val(Me.txtYears)
For intI = 1 To intYears
sngTotal2 = sngTotal * (1 + sngInterest) ^ intI
Next
For intI = 1 To (intYears * 2)
sngTotal3 = sngTotal * 2 * (1 + sngInterest) ^ intI
Next
For intI = 1 To (intYears * 3)
sngTotal4 = sngTotal * 3 * (1 + sngInterest) ^ intI
Next intI
Me.lblResult1.Caption = "At the end of " & intYears & " years " & vbCrLf & "the total savings will be " & FormatCurrency(Int(sngTotal2), 2)
Me.lblResult2.Caption = "If you invest " & sngTotal * 2 & " for " & intYears * 2 & " years" & vbCrLf & "the total savings will be " & FormatCurrency(Int(sngTotal3), 2)
Me.lblResult3.Caption = "If you invest " & sngTotal * 3 & " for " & intYears * 3 & " years" & vbCrLf & "the total savings will be " & FormatCurrency(Int(sngTotal4), 2)
End If