Option Compatible turns on the VBA-compatible Basic compiler mode at the module level. The function CompatibilityMode() controls runtime mode and affects all code executed after setting or resetting the mode.This option may affect or assist in the following situations:Allow special characters as identifiers.Create constants including non-printable characters.Support Private/Public keywords for procedures.Compulsory Set statement for objects.Default values for optional parameters in procedures.Named arguments when multiple optional parameters exist.Preload of %PRODUCTNAME Basic librariesOption Compatible is required when coding class modules.Option Compatible
CompatibilityMode() Function
CompatibilityMode() function is controlling runtime mode and affects all code executed after setting or resetting the mode. Option Compatible turns on VBA compatibility at module level for the %PRODUCTNAME Basic compiler.Use this feature with caution, limit it to document conversion situations for example.This function may affect or help in the following situations:Creating enumerations with Enum statementUpdating Dir execution conditionsRunning RmDir command in VBA modeChanging behaviour of Basic Dir commandCompatibilityMode() function may be necessary when resorting to Option Compatible or Option VBASupport compiler modes.CompatibilityMode(True | False)
Refer to Identifying the Operating System and Getting Session Information for Option Compatible simple examples, or Access2Base shared Basic library for other class examples making use of Option Compatible compiler mode.
Variables scope modification in Using Procedures and Functions with CompatibilityMode() function.