Visual Basic Compiler Options |
|
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
- Open the project's Property Pages dialog box. For details, see <Projectname> Property Pages Dialog Box.
- Click the Common Properties folder.
- Click the Build property page.
- Modify the Option Strict property.
To set /optionstrict programmatically
- See OptionStrict Property.
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