Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Stop a Procedure from another procedure | Excel Discussion (Misc queries) | |||
Calling a procedure in a procedure | Excel Programming | |||
Calling a procedure in a procedure | Excel Programming | |||
Calling a procedure in a procedure | Excel Programming |