IBM Lotus Symphony
|
定义可以用作表达式的子例程以确定返回类型。
请参阅“参数”
语法
Function Name[(VarName1 [As Type][, VarName2 [As Type][,...]]]) [As Type]
语句块
[Exit Function]
语句块
End Function
参数
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