Visual Basic Compiler Options  

/optionstrict

Enforces strict type semantics to restrict implicit type conversions.

/optionstrict[+ | -]

Arguments

+ | -
/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.

Remarks

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

Example

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