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

Please visit our partners


Windows Technology Windows Technology
15 Seconds
4GuysFromRolla.com
ASP 101
ASP Wire
VB Forums
VB Wire
WinDrivers.com
internet.commerce internet.commerce
Partners & Affiliates














ASP 101 is an
internet.com site
ASP 101 is an internet.com site
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
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 @ Microsoft.com
What is Adovbs.inc and Why Do I Need It?
An Overview of ASP.NET

QUICK TIP:
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: webmaster@asp101.com.


Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

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