Function Statement

Defines a subroutine that can be used as an expression to determine a return type.

Syntax

pogledaj Parametre

Parametri:

Syntax

Sub Naziv[(VarNaziv1 [As Tip][, VarNaziv2 [As Tip][,...]])]

blok izraza

[Exit Function]

blok izraza

End function

Parametar

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.

Primjer:

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 Returns 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