IBM Lotus Symphony
|
在子例程或函数中声明过程级的变量或数组,使得在退出子例程或函数后,这些变量或数组的值仍能保留。Dim 语句的约定仍然有效。
![]() |
Static 语句不能用于定义可变数组。必须根据固定大小来指定数组。 |
Static VarName[(start To end) ] [As VarType], VarName2[(start To end) ] [As VarType], ...
Sub ExampleStatic
Dim iCount as Integer, iResult as Integer
For iCount = 0 to 2
iResult = InitVar()
Next iCount
MsgBox iResult,0,"The answer is"
End Sub
REM Function for initialization of the static variable
Function InitVar() As Integer
Static iInit As Integer
Const iMinimum as Integer = 40 REM minimum return value of this function
if iInit = 0 then REM check if initialized
iInit = iMinimum
else
iInit = iInit + 1
end if
InitVar = iInit
End Function