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.

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 | Option Strict Statement