VB5, VB6Send Messages With the XForm Control
Public Function MessageForm(TargetForm As Object, _
   NewMessage As String) As Boolean
Dim oObject As Control
MessageForm = False
'Search for the XForm on the target form and ping it
Set oObject = GetXFormControl(TargetForm)
If Not oObject Is Nothing Then
   Call oObject.Ping(NewMessage)
   MessageForm = True
End If
End Function

Public Function GetXFormControl(Optional poForm _
   As Variant) As Object
Dim oObject As Object
Dim oForm As Object
'Clear GetXFormControl function return
Set GetXFormControl = Nothing
'If no form was specified, use the form's parent
If Not IsMissing(poForm) Then
   Set oForm = poForm
Else
   Set oForm = coParent
End If
'Trap for errors and search for the XForm control
On Error GoTo Failure
For Each oObject In oForm.Controls
   If TypeOf oObject Is XForm Then
      Set GetXFormControl = oObject
      Exit For
   End If
Next oObject
Failure:
End Function
Listing 4 MessageForm uses the GetXFormControl function to search the targeted form for the control. vVariable is a place holder, because events don't support optional parameters.