ID : 5165
Static
Function
To declare a local variable with Static attribute.
Syntax
Static variable name As data type[ = initial value][, variable name As data type[ = initial value]]
Guaranteed entry
- Variable name
- Designate a variable name. Each name must be specified in accordance with the Naming convention. Also an Array can be declared.
- Data type
- Designate a data type of each local variable to declare.
- Initial value
- Designate a value to be assigned when variable declaration. Designate constant.
Description
Declare local variable with Static attribute.
With separator ",", you can declare multiple variables on a line.
Designate data type using the following identifiers.
Related Terms
Declaration Statement, Local Variable, Static Attribute, Public Attribute, Dim
Attention
Static attribute cannot be added to I/O type local variable.
As to string type local variable, its data size varies depending on with/without Static attribute.
Initial value will be assigned only when creating a declared variable. In the case of Static local variable, a default will be assigned at the time of compile, not at the task execution.
Example
Static aaa As Integer = 30
Static bbb(5) As Position
Sub Main
Static ccc As Position
' Statements
End Sub
ID : 5165