Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Static and Dim outside procedure

Hi,

Could someone please tell me what's the different between Static statement
and Dim variables with Public and at module level?
Because I find that both way retain value.

Thanks
Regards
Augustus
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Static and Dim outside procedure

augustus,
<From Help, Search="Static"
Static Statement

Used at procedure level to declare variables and allocate storage space.
Variables declared with the Static statement retain their values as long as
the code is running.
Syntax
Static varname[([subscripts])] [As [New] type] [, varname[([subscripts])]
[As [New] type]] . .

</From Help

<From Help, Search="Scope"
Understanding Scope and Visibility

Scope refers to the availability of a variable, constant, or procedure for
use by another procedure. There are three scoping levels: procedure-level,
private module-level, and public module-level.
You determine the scope of a variable when you declare it. It's a good idea
to declare all variables explicitly to avoid naming-conflict errors between
variables with different scopes.

</From Help

NickHK

"augustus" wrote in message
...
Hi,

Could someone please tell me what's the different between Static statement
and Dim variables with Public and at module level?
Because I find that both way retain value.

Thanks
Regards
Augustus



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Static and Dim outside procedure

Hi

If variable declared with Public and at the Declarations section of module
could have the same effect as Static within a procedure, ie the variable
retain their values as long as the code running, then whats the point of
having Static?

Thanks
Regards
Augustus

"NickHK" wrote:

augustus,
<From Help, Search="Static"
Static Statement

Used at procedure level to declare variables and allocate storage space.
Variables declared with the Static statement retain their values as long as
the code is running.
Syntax
Static varname[([subscripts])] [As [New] type] [, varname[([subscripts])]
[As [New] type]] . .

</From Help

<From Help, Search="Scope"
Understanding Scope and Visibility

Scope refers to the availability of a variable, constant, or procedure for
use by another procedure. There are three scoping levels: procedure-level,
private module-level, and public module-level.
You determine the scope of a variable when you declare it. It's a good idea
to declare all variables explicitly to avoid naming-conflict errors between
variables with different scopes.

</From Help

NickHK

"augustus" wrote in message
...
Hi,

Could someone please tell me what's the different between Static statement
and Dim variables with Public and at module level?
Because I find that both way retain value.

Thanks
Regards
Augustus




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
Stop a Procedure from another procedure Ayo Excel Discussion (Misc queries) 1 October 30th 08 01:42 AM
Calling a procedure in a procedure Norman Jones Excel Programming 8 August 20th 04 07:53 PM
Calling a procedure in a procedure N10 Excel Programming 2 August 18th 04 12:49 AM
Calling a procedure in a procedure Don Guillett[_4_] Excel Programming 1 August 17th 04 11:31 PM


All times are GMT +1. The time now is 01:56 AM.

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

About Us

"It's about Microsoft Excel"