Static Statement

λ³€μˆ˜λ‚˜ λ°°μ—΄μ˜ 값이 μ„œλΈŒλ£¨ν‹΄ λ˜λŠ” ν•¨μˆ˜κ°€ μ’…λ£Œλœ 후에도 μœ μ§€λ˜λ„λ‘ λ³€μˆ˜λ‚˜ 배열을 μ„œλΈŒλ£¨ν‹΄ λ˜λŠ” ν•¨μˆ˜ λ‚΄μ˜ ν”„λ‘œμ‹œμ € μˆ˜μ€€μ—μ„œ μ„ μ–Έν•©λ‹ˆλ‹€. λ˜ν•œ 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

Please support us!