Professional Documents
Culture Documents
Introduction
The compound interest is the amount of money earned on a deposit during a period of time. It can be calculated using the following formula:
P = Principal r = Annual (Interest) Rate m = Number of Compounding Periods per Year n = Total Number of Compounding Periods A = Amount Earned After n periods
TextBox Label Caption Principal: Interest Rate: Periods: TextBox Label Caption Interest Earned: Amount Earned: TextBox Name txtInterestEarned txtAmountEarned Format Currency Currency Decimal Places 2 2 Default Value 0 0 TextBox Name txtPrincipal txtInterestRate txtPeriods Format Currency Percent General Number 0 Decimal Places 2 Default Value 0 0.0825 0
17. Implement the Click() event of the Calculate button as follows: Option Compare Database Option Explicit Private Dim Dim Dim Dim Dim Dim Dim Dim Dim Sub cmdCalculate_Click() Principal As Currency InterestRate As Double InterestEarned As Currency FutureValue As Currency RatePerPeriod As Double Periods As Integer CompoundType As Integer i As Double n As Integer
Principal = CCur(txtPrincipal) InterestRate = CDbl(txtInterestRate) If fraFrequency.Value = 1 Then CompoundType = 12 ElseIf fraFrequency.Value = 2 Then CompoundType = 4 ElseIf fraFrequency.Value = 3 Then CompoundType = 2 Else CompoundType = 1 End If Periods = CInt(txtPeriods) i = InterestRate / CompoundType n = CompoundType * Periods RatePerPeriod = InterestRate / Periods FutureValue = Principal * ((1 + i) ^ n) InterestEarned = FutureValue - Principal txtInterestEarned = CStr(InterestEarned) txtAmountEarned = CStr(FutureValue) End Sub Private Sub cmdClose_Click() On Error GoTo Err_cmdClose_Click
DoCmd.Close Exit_cmdClose_Click: Exit Sub Err_cmdClose_Click: MsgBox Err.Description Resume Exit_cmdClose_Click End Sub 18. Test the form
Home