Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default variable dimensions

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default variable dimensions

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default variable dimensions

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
LOOKINGUP IN 2 DIMENSIONS FARAZ QURESHI Excel Discussion (Misc queries) 1 December 18th 08 11:56 AM
Fix dimensions Niniel Excel Discussion (Misc queries) 15 October 11th 07 03:47 PM
Convert dimensions Niniel Excel Discussion (Misc queries) 13 October 4th 07 09:10 PM
lookup on 2 (and 3!) dimensions [email protected] Excel Discussion (Misc queries) 2 April 11th 06 05:05 PM
Three Dimensions? Charminster Developments New Users to Excel 2 November 3rd 05 04:58 PM


All times are GMT +1. The time now is 12:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"