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