例: Contains method (NotesDocumentCollection - LotusScript®)

この例では、削除する文書にキャレット文書がない場合、ビューからの削除を禁止します。

Sub Querydocumentdelete(Source As Notesuidatabase, Continue As Variant)
  ' We've had a problem in this database of people deleting documents
  ' accidentally because they didn't know the difference between 
  ' highlighted and selected documents. They keep complaining that the
  ' delete "didn't work the first time" and doing it again, not realizing 
  ' they deleted other docs. So, prohibit deletion from a view unless
  ' the caret document is among those being deleted, so the delete will 
  ' never appear to have done nothing.
  Dim wksp As New NotesUIWorkspace
  Dim uivu As NotesUIView
  Dim docsToBeDeleted As NotesDocumentCollection
  
  Set uivu = wksp.CurrentView
  If Not (uivu Is Nothing) Then
    Dim strID As String
    strID = uivu.CaretNoteID
    Set docsToBeDeleted = Source.Documents
    If Not docsToBeDeleted.Contains(strID) Then
      Msgbox "Error: you have selected some documents but the highlighted document is not one of them.", 0, "Delete documents"
      Continue = False
    Elseif docsToBeDeleted.Count > 1 Then
      ' if they're deleting more than one doc make sure they know it
      Msgbox "Deleting " & docsToBeDeleted.Count & " documents.", 0, "Delete documents"
    End If
  End If
End Sub