IBM Lotus Symphony
|
処理結果を戻り値として返すサブルーチンを定義します。
see Parameter
構文
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 配列にテスト用データを代入
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 はテキスト配列 sList( ) 内に指定文字列を検索
REM 戻り値は、該当するインデックス値またはゼロ (NULL)
for iCount=1 to Ubound( sList() )
if sList( iCount ) = sItem then
exit for REM 検索で sItem がヒット
end if
Next iCount
if iCount = Ubound( sList() ) then iCount = 0
LinSearch = iCount
end function