This is a function i want to use to predict the amount of money lost inflation after a number of years.
option compatible
Function INFLATION_ADJUSTMENT(ParamArray xData(),ParamArray yData(),AMT,year) As Double
dim r as single
dim r0 as single
dim Amplitude as single
dim Period as single
dim delta_X as single
dim delta_Y as single
dim Y as single
dim H as single
dim V as single
dim Inflation_Rate0 as single
dim Inflation_Rate as single
delta_X = xData(1)-xData(0)
delta_Y = yData(1)-yData(0)
Y = delta_Y/delta_X REM The Derivative of y
Amplitude = Math.SQRT(yData(0)^2+Y^2)
Period = 2*Math.PI()/(UBOUND(xData))
H = Math.ASIN(yData(0)/Amplitude)
REM The Average of the yData = the verticle shift constant
For n = 0 to UBOUND(xData)
V = V + yData(n)/UBOUND(xData)
Next n
For i = 1 to year
Inflation_Rate0 = (Amplitude*Math.SIN(Period*(0)+H)+V)
Inflation_Rate = (Amplitude*Math.SIN(Period*(i)+H)+V)
r0 = AMT*Inflation_Rate0/100
r = r0 + r*Inflation_Rate/100
Next i
INFLATION_ADJUSTMENT = r
End Function
As you may know, I am getting an error on the line of code where I try to compute xData(1)-xData(0).
The Error is: Inadmissible Value or Data Type. Index out of defined range.Any way I could make this better?