ASP 101 - Active Server Pages 101 - Web01
The Place ASP Developers Go!

Please visit our partners

Windows Technology Windows Technology
15 Seconds
ASP 101
ASP Wire
VB Forums
VB Wire
internet.commerce internet.commerce
Partners & Affiliates

ASP 101 is an site
ASP 101 is an site
Internet News
Small Business
Personal Technology

Corporate Info
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash

 Top ASP 101 Stories Top ASP 101 Stories
The Top 10 ASP Links @
What is and Why Do I Need It?
An Overview of ASP.NET

Stop Users from Double Clicking
Show All Tips >>
ASP 101 RSS Feed ASP 101 Updates

Quick Tips

Use Option Strict

For years I've been telling people that they shouldn't write any VB or VBScript code without first specifying Option Explicit. Well, times change and I no longer use Option Explicit. These days it's Option Strict.

In VB.NET, just declaring your variables isn't enough anymore. In order for your code to perform at its best, you really should include type information when you declare your variables:

Dim intLoopVar As Integer
Dim strFirstName As String = "John"

In order to require you to assign types to all your variables, use the Option Strict compiler option. If you're using VB.NET, you can use Option Strict anywhere you can use Option Explicit. If you want to use it in an ASP.NET web form, simply add the Strict attribute to the Page directive:

<%@ Page Language="VB" Strict="True" %>

Once you add the Strict attribute, any attempt to run the page without specifying the types of your variables will result in a compilation error something like this:

Compiler Error Message: BC30209: Option Strict On requires all variable declarations to have an 'As' clause.

Previous      Show All Tips      Next

If you have a tip you would like to submit, please send it to:

Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback
The Network for Technology Professionals



Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers