How to enable the "Option Strict" and "Option Explicit" statements in Visual Basic applications (911793)



The information in this article applies to:

  • Microsoft Visual Basic 2005
  • Microsoft Visual Basic .NET (2003)
  • Microsoft Visual Basic .NET (2002)

INTRODUCTION

This article describes how to enable the Option Strict and Option Explicit statements in Microsoft Visual Basic applications for code-behind files and files that are contained in the App_Code folder.

MORE INFORMATION

To enable the Option Strict and Option Explicit statements in the code-behind files and files that are contained in the App_Code folder of a Visual Basic application, override the compiler configuration in the system.codedom section of the Web.config file for the application. To do this, add the following code to the Web.config file:
	<system.codedom>
		<compilers>
		<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="0"  />
		<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="0" />
		</compilers>
	</system.codedom>

REFERENCES

For more information about how to create the Web.config file for an ASP.NET application, click the following article number to view the article in the Microsoft Knowledge Base:

815179 How to create the Web.config file for an ASP.NET application


Modification Type:MinorLast Reviewed:10/3/2006
Keywords:kbhowto kbtshoot kbinfo KB911793 kbAudDeveloper