variable dimensions

  • Thread starter Thread starter mareharbor
  • Start date Start date
M

mareharbor

I have a question regarding the syntax of the below code. This macro
is a using a function on the sheet with the variables dimensioned in
"function price". I am not that familiar with this type of coding and
i have a question about variables like "timestep", "u","d","p", and
"discountFactor" that are not dimensioned. How does this work that you
do not need to delcare these? I am familiar with temp variables, is
this similiar? Note:this is not the whole code. Any help would be
great. Thanks



Function Price(Asset As Double, Volatility As Double, IntRate As
Double, _
Strike As Double, Expiry As Double, NoSteps As
Integer)
ReDim s(0 To NoSteps)
ReDim V(0 To NoSteps)
timestep = Expiry / NoSteps
DiscountFactor = Exp(-IntRate * timestep)
temp1 = Exp((IntRate + Volatility * Volatility) * timestep)
temp2 = 0.5 * (DiscountFactor + temp1)
u = temp2 + Sqr(temp2 * temp2 - 1)
d = 1 / u
p = (Exp(IntRate * timestep) - d) / (u - d)
 
They are not declared because the project doesn't force explicit variable
declaration.

Add

Option Explicit

at the head of the module, and they will then need to be declared.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
I suspect that these variables have been declared eith in a Global/Public
Variable module, or in the Sub routine that calls this function
 
Back
Top