例: Evaluate 関数とステートメント

' For each document in a Notes database, use a Notes macro to
' compute the average for a list of numeric entries in the 
' NumberList field. Evaluate returns a Variant, and Notes 
' macros return an array. In this case, the array contains only 
' 1 element (element 0). For more info, see the Notes
' documentation.

Sub Click(Source As Button)
   ' The macro text must be known at compile time.
   Const NotesMacro$ = "@Sum(NumberList) / @Elements(NumberList)"
   Dim result As Variant, j As Integer
   Dim db As New NotesDatabase("", "MYSALES.NSF")
   Dim dc As NotesDocumentCollection
   Dim doc As NotesDocument
   Set dc = db.AllDocuments
   Set doc = dc.GetFirstDocument( )
   Do Until doc Is Nothing
      result = Evaluate(NotesMacro$, doc)
      MessageBox("Average is " & result(0))      
       Set doc = dc.GetNextDocument(doc)
   Next
EndSub