Enforces strict type semantics to restrict implicit type conversions.
When /optionstrict+ is in effect, only widening type conversions can be made implicitly. Implicit narrowing type conversions, such as assigning a Decimal type object to an integer type object, are reported as errors.
To generate warnings for implicit narrowing type conversions, use /optionstrict:custom. Use /nowarn:numberlist to ignore particular warnings and /warnaserror:numberlist to treat particular warnings as errors.
To set /optionstrict in the Visual Studio IDE
Have a project selected in Solution Explorer. On the Project menu, click Properties. For more information, see Introduction to the Project Designer.
Click the Compile tab.
Modify the value in the Option Strict box.
To set /optionstrict programmatically
The following code compiles Test.vb using strict type semantics.
vbc /optionstrict+ test.vb