Function Statement

๋ฐ˜ํ™˜ ์œ ํ˜•์„ ๊ฒฐ์ •ํ•˜๊ธฐ ์œ„ํ•ด ์‹์œผ๋กœ ์‚ฌ์šฉ๋  ์ˆ˜ ์žˆ๋Š” ์„œ๋ธŒ๋ฃจํ‹ด์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.

๊ตฌ๋ฌธ

๋งค๊ฐœ ๋ณ€์ˆ˜ ์ฐธ์กฐ

๋งค๊ฐœ ๋ณ€์ˆ˜:

๊ตฌ๋ฌธ

Function Name[(VarName1 [As Type][, VarName2 [As Type][,...]]]) [As Type]

๋ฌธ ๋ธ”๋ก

[Exit ํ•จ์ˆ˜]

๋ฌธ ๋ธ”๋ก

End ํ•จ์ˆ˜

๋งค๊ฐœ ๋ณ€์ˆ˜

Name: ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ตฌํ•˜๋Š” ๊ฐ’์„ ํฌํ•จํ•  ์„œ๋ธŒ๋ฃจํ‹ด์˜ ์ด๋ฆ„์ž…๋‹ˆ๋‹ค.

VarName: ์„œ๋ธŒ๋ฃจํ‹ด์— ์ „๋‹ฌํ•  ๋งค๊ฐœ ๋ณ€์ˆ˜์ž…๋‹ˆ๋‹ค.

Type: ์œ ํ˜• ์„ ์–ธ ํ‚ค์›Œ๋“œ์ž…๋‹ˆ๋‹ค.

์˜ˆ:

Sub ExampleExit

Dim sReturn As String

Dim sListArray(10) As String

Dim siStep As Single

    For siStep = 0 to 10 REM Fill array with test data

        sListArray(siStep) = chr$(siStep + 65)

        MsgBox sListArray(siStep)

    Next siStep

    sReturn = LinSearch(sListArray(), "B")

    Print sReturn

End Sub

 

Function LinSearch( sList(), sItem As String ) As Integer

Dim iCount As Integer

REM Linsearch searches a TextArray:sList() for a TextEntry:

REM Return value is the index of the entry or 0 (Null)

    For iCount=1 To Ubound( sList() )

        If sList( iCount ) = sItem Then

            Exit for REM sItem found

        End If

    Next iCount

    If iCount = Ubound( sList() ) Then iCount = 0

    LinSearch = iCount

End Function