Examples: Using the Evaluate statement

  1. This example calls @ProperCase when exiting the Subject field. The result of Evaluate replaces the current value of the Subject item.
    Sub Exiting(Source As Field)
      Dim workspace As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Dim doc As NotesDocument
      Dim eval As Variant
      Set uidoc = workspace.CurrentDocument
      Set doc = uidoc.Document
      eval = Evaluate("@ProperCase(Subject)", doc)
      Call doc.ReplaceItemValue("Subject", eval)
      Call doc.Save(True, False)
    End Sub
  2. This button example calls @Sum, then displays the sum of the values in the Amounts field.
    Sub Click(Source As Button)
      Dim workspace As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Dim doc As NotesDocument
      Dim sumAmounts As Variant
      Set uidoc = workspace.CurrentDocument
      Set doc = uidoc.Document
      sumAmounts = Evaluate("@Sum(Amounts)", doc)
      Messagebox("Sum of Amounts = " & sumAmounts(0))
    End Sub