WineSnob
Not Bright but TENACIOUS
- Local time
- Today, 17:42
- Joined
- Aug 9, 2010
- Messages
- 211
I am trying to change a calculation every 6 years if a variable is true. Here is what I have. (see the comments after If nInflYear = 5 Then)
There is a test function below using the arguments. The correct answer will be 5000,5000,5000,5000,5000,5796.37. So every 6th year the calc changes.
Public Function zCalcIncome(nYears As Integer, nStartingYear As Integer, ClientMonthlyInc As Currency, InflationFactor As Double, nInflYear As Double) As Currency
Dim i As Integer
For xYear = nStartingYear To (nStartingYear + (nYears - 1))
If nInflYear = 1 Then
StartIncomeAmt = ClientMonthlyInc * (1 + InflationFactor) ^ (xYear - 1)
'MsgBox "Year " & xYears & " " & StartIncomeAmt
Debug.Print "Year: " & xYear & " " & "MonthlyIncome: " & StartIncomeAmt
End If
If nInflYear = 5 Then
StartIncomeAmt = ClientMonthlyInc '***Until Year 6,11,16,(every 5 years LETS CALL IT fYears) Then the calculation will be
'StartIncomeAmt = ClientMonthlyInc * (1 + InflationFactor) ^ (fYears - 1)
'MsgBox "Year " & xYears & " " & StartIncomeAmt
Debug.Print "Year: " & xYear & " " & "MonthlyIncome: " & StartIncomeAmt
End If
zCalcIncome = StartIncomeAmt
Next xYear
End Function
________________________________________________
Function GetMonthincome()
''(nYears, nStartingYear, ClientMonthlyInc, InflationFactor , nInflYear
Debug.Print zCalcIncome(6, 1, 5000, 0.03, 5)
End Function
There is a test function below using the arguments. The correct answer will be 5000,5000,5000,5000,5000,5796.37. So every 6th year the calc changes.
Public Function zCalcIncome(nYears As Integer, nStartingYear As Integer, ClientMonthlyInc As Currency, InflationFactor As Double, nInflYear As Double) As Currency
Dim i As Integer
For xYear = nStartingYear To (nStartingYear + (nYears - 1))
If nInflYear = 1 Then
StartIncomeAmt = ClientMonthlyInc * (1 + InflationFactor) ^ (xYear - 1)
'MsgBox "Year " & xYears & " " & StartIncomeAmt
Debug.Print "Year: " & xYear & " " & "MonthlyIncome: " & StartIncomeAmt
End If
If nInflYear = 5 Then
StartIncomeAmt = ClientMonthlyInc '***Until Year 6,11,16,(every 5 years LETS CALL IT fYears) Then the calculation will be
'StartIncomeAmt = ClientMonthlyInc * (1 + InflationFactor) ^ (fYears - 1)
'MsgBox "Year " & xYears & " " & StartIncomeAmt
Debug.Print "Year: " & xYear & " " & "MonthlyIncome: " & StartIncomeAmt
End If
zCalcIncome = StartIncomeAmt
Next xYear
End Function
________________________________________________
Function GetMonthincome()
''(nYears, nStartingYear, ClientMonthlyInc, InflationFactor , nInflYear
Debug.Print zCalcIncome(6, 1, 5000, 0.03, 5)
End Function