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