例: FindNextString method

次のエージェントは、現在 (または最初に) 選択されている文書の Body アイテムでユーザーが入力した文字列と一致する次の文字列を検索します。

Dim session As NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim body As NotesRichTextItem
Dim rtnav As NotesRichTextNavigator
Dim rtrange As NotesRichTextRange

Sub Initialize
  Set session = New NotesSession
  Set db = session.CurrentDatabase
  Set dc = db.UnprocessedDocuments
  If dc.Count = 0 Then
    Messagebox "No document selected",, "No doc"
    Exit Sub
  End If
  Set doc = dc.GetFirstDocument
  Set body = doc.GetFirstItem("Body")
  Set rtnav = body.CreateNavigator
  Set rtrange = body.CreateRange
  searchString$ = Inputbox$("Enter the search string", _
  "Search string")
  If searchString$ = "" Then Exit Sub
  If rtnav.FindFirstString(searchString$, _
  RT_FIND_CASEINSENSITIVE) Then
    Do
      Call rtrange.SetBegin(rtnav)
      Messagebox rtrange.TextRun,, searchString$
    Loop While rtnav.FindNextString(searchString$, _
    RT_FIND_CASEINSENSITIVE)
  Else
    Messagebox searchString$,, "String not found"
  End If
End Sub