Function Statement
Define un método que se pode usar como expresión para determinar un tipo de retorno.
Sintaxe
ver Parámetros
Parámetros:
Sintaxe
Function Nome[(NomeVar1 [As Tipo][, NomeVar2 [As Tipo][,...]]]) [As Tipo]
bloque de instrucións
[Exit Function]
bloque de instrucións
End Function
Parámetro
Name: Name of the subroutine to contain the value returned by the function.
VarName: Parameter to be passed to the subroutine.
Type: Type-declaration keyword.
Exemplo:
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
' BuscaLin busca en MatrizTexto:sLista() unha EntradaTexto:
REM O valor de retorno é o índice da entrada ou 0 (Nulo)
For iCount=1 To Ubound( sList() )
If sList( iCount ) = sItem Then
Exit for REM sElemen encontrado
End If
Next iCount
If iCount = Ubound( sList() ) Then iCount = 0
LinSearch = iCount
End Function