This documentation is archived and is not being maintained.

OptionStrict Property

Visual Studio .NET 2003

Indicates whether implicit narrowing conversions are allowed. Visual Basic projects only. For more information on data conversions, see Widening and Narrowing Conversions.

[Visual Basic .NET]
Public Property OptionStrict() As prjOptionStrict
[Visual Basic 6]
Property Get OptionStrict() As prjOptionStrict
Property Let OptionStrict( _
   ByVal OnOrOff As prjOptionStrict _
HRESULT __stdcall get_OptionStrict(
   /* [out, retval] */ prjOptionStrict* retVal
HRESULT __stdcall put_OptionStrict(
   /* [in] */ prjOptionStrict OnOrOff
prjOptionStrict OptionStrict {get; set;}
[JScript .NET]
public function get OptionStrict() : prjOptionStrict
public function set OptionStrict(
   OnOrOff: prjOptionStrict


A prjOptionStrict enumeration value. If prjOptionStrict.prjOptionStrictOn, then a narrowing conversion will generate an error at compile time. The default value for new projects is prjOptionStrictOff.


Using the prjOptionStrictOn enumeration value prohibits implicit narrowing conversions, such as converting a long value to an integer value. Explicit conversions, using CType and other conversion functions, must be used instead. Note that even explicit conversions may fail at run time. For example, it is not possible to convert the string "ball" to an integer value.

This property may be overridden for a particular project item by using the Option Strict Statement.

This property is not meaningful in Visual C# projects.


See ProjectType Property.

See Also

Option Strict Statement | Widening and Narrowing Conversions | CType Function | Build, Common Properties, <Projectname> Property Pages Dialog Box

Applies To: Properties Property (General Extensibility) | Properties Property (Visual Basic and Visual C# Project Object)