# 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`