This documentation is archived and is not being maintained.


Enforces strict type semantics to restrict implicit type conversions.

/optionstrict[+ | -]


+ | -
/optionstrict+ restricts implicit type conversion. The default for this option is /optionstrict-; /optionstrict- is the same as /optionstrict. Both let you use permissive type semantics.


When /optionstrict+ is in effect, only widening type conversions can be done implicitly. Implicit narrowing type conversions, such as assigning a Decimal type object to an integer type object, are reported as errors.

To set /optionstrict in the Visual Studio integrated development environment

  1. Open the project's Property Pages dialog box. For details, see <Projectname> Property Pages Dialog Box.
  2. Click the Common Properties folder.
  3. Click the Build property page.
  4. Modify the Option Strict property.

To set /optionstrict programmatically

  • See OptionStrict Property.


The following code compiles test.vb using strict type semantics:

vbc /optionstrict+ test.vb 

See Also

Visual Basic Compiler Options | /optionexplicit | Sample Compilation Command Lines | Option Strict Statement