variable dimensions

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)
 
B

Bob Phillips

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)
 
S

steve_doc

I suspect that these variables have been declared eith in a Global/Public
Variable module, or in the Sub routine that calls this function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top