From Xojo Documentation

Property (As Boolean )
aPushButton.Cancel = newBooleanValue
BooleanValue = aPushButton.Cancel

Supported for all project types and targets.

If True, the Escape key and Command-Period key sequence are mapped to the button. The default is False.

Sample Code

This example makes the PushButton a cancel button. It is in the Open event of the control.

Me.Cancel = True