LibreOfficeDev 7.4 Hjelp
A function is a block of code which runs when it is called. A function is usually called in an expression.
You can pass data, known as parameters or arguments, into a function. You may pass a parameter by value or by reference. When by reference, modifications applied to the parameter in the function will be sent back to the calling code.
A function usually returns data as a result.
[Private | Public] Function Name[char] (argument1 [As Type][, argument2[char][,...]]) [As typename]
uttrykk
[Exit Function]
uttrykk
End Function
scope: «Function» sitt omfang er Public. Eit Private omfang er ein intern rutine i ein modul, ikkje tenkt brukt frÄ andre modular.
Namn: Namnet pÄ subrutiinen som inneheld verdien som vert returnert av funksjonen.
arguments Parameter som skal sendast til subrutinen.
Sub ExampleExit
Dim sReturn As String
Dim sListArray(10) As String
Dim siStep As Single
For siStep = 0 To 10 ' Fyll tabellen med testdata
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
' Linsearch sĂžkjer ei TextArray:sList() etter eit TextEntry:
' Returverdien er indeksen for oppfĂžringa eller 0 (Null)
For iCount=1 To Ubound( sList() )
If sList( iCount ) = sItem Then
Exit For ' sItem funne
End If
Next iCount
If iCount = Ubound( sList() ) Then iCount = 0
LinSearch = iCount
End Function