Noting Form State

Your form can note (to some extent) whether the Submit or Cancel button was clicked; such as to set the value of an output parameter.

If Cancel is pressed, neither ValidateForm nor TransferDataOut are called, so setting an output parameter only has an effect if Submit is pressed. If the parameter is bound to something (for example, an input parameter of a subsequent form), then the target object remains with its default value if Cancel is pressed.

An example of this is contained in the sample form UsersFormVB:

Public Overloads Overrides Sub TransferDataOut()
        _selection = UsersListBox.SelectedItem
        _status = "Form Submitted"
    End Sub