Method

UserCancelled


Description

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.

Usage

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.

Sample code

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

Compatibility

All project types on all supported operating systems.

See also

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