UserCancelled

From Xojo Documentation

Revision as of 21:16, 5 January 2022 by Gperlman (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!


Method

Used to determine if the user has pressed Escape (on Windows or Linux) or Command-period (on macOS) or to cancel the execution of code.

Syntax

result = UserCancelled

Part Type Description
result Boolean Result is True if the user has pressed Escape (on Windows or Linux) or Command-period (on macOS) or and False if the user did not cancel.

Notes

The UserCancelled function will continue to return True until the event handler that was executing when the user pressed Escape or Command-period is finished.

Examples

This example uses the UserCancelled function to exit a For loop if the user presses Command-period/Escape.

Const kMax = 10000000

For i As Integer = 0 To kMax
ProgressBar1.Value = (i / kMax) * ProgressBar1.Maximum
If UserCancelled Then
Exit
End If
Next

See Also

Exit, Do...Loop, For...Next, While...Wend statements; Application class.