Tuesday, October 28, 2008

LotusScript equivalents for the @Word

Function Word (sourceString As String, separator As String, number As Integer) As String
'LotusScript equivalents for the @Word
searchString$=SourceString & separator ' add one separator to catch also the last substring
For i% = 1 To number
pos%=Instr(searchString$, separator)
If pos%=0 Then Exit For
substring$=Left(searchString$,pos%-1)
searchString$=Mid(searchString$, pos%+1)
Next
If pos% > 0 Then
Word=substring$
Else
Word=""
End If
End Function

No comments: