Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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) |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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) wrote in message ups.com... 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) |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I suspect that these variables have been declared eith in a Global/Public
Variable module, or in the Sub routine that calls this function " wrote: 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) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
LOOKINGUP IN 2 DIMENSIONS | Excel Discussion (Misc queries) | |||
Fix dimensions | Excel Discussion (Misc queries) | |||
Convert dimensions | Excel Discussion (Misc queries) | |||
lookup on 2 (and 3!) dimensions | Excel Discussion (Misc queries) | |||
Three Dimensions? | New Users to Excel |