Function Main As String
  Dim Answer As Integer
  Answer=MessageBox("My, you are looking well!","Example #1", MBB_OK +MBI_EXCLAMATION)
  Answer=MessageBox("Have you been on a diet?","Example #1", MBB_YESNO + MBI_QUESTION)
  If Answer= MBR_YES Then
    Call GreetThemAll
    Main="Everybody has been weighed."
  Else
    Main="Sorry, time to leave."
  End If
End Function

Sub GreetThemAll
Dim Diagram As Object, Answer As Integer, MolWeight As Double, Tail As String
Tail=Chr(13)+Chr(13)+Chr(13)+"Greet the next?"
With ActiveDocument.ActivePage.Diagrams
  For Each Diagram in .Self
    MolWeight=Diagram.GetMolWeight
    If MolWeight=0.0 Then MolWeight=-99.99
    Answer=MessageBox("Hmmm, you weigh "+LTrim(FStr(MolWeight,12,4))+" a.u.!!"+Tail,"Example #1a", MBB_YESNO+MBI_EXCLAMATION)
    If Answer= MBR_NO  Then Exit For
  Next Diagram
End With
End Sub
