What is the importance of the Option statement?

The Option statement is used to prevent syntax and logical errors in code. The possible suffixes of this statement are:

  • Option Explicit: Is the default abd is On. Option Explicit requires declaration of all variables before they are used.
  • Option Compare: This can be set to Binary or Text and it specifies if stringsp are to be compared using binary or text comparison operations.
  • Option Strict: The default is Off. An example: If value of one data type is assigned to another then Visual Basic will consider that as an error. If you want to assign a value of one Type to another then you should set it to On and use the conversion functions.
Example using the Option Statement.

The following code does not perform any special function but will show where to place an Option statement.

Option Strict Off
Imports System
Module Module 1
Sub Main ()
Console.WriteLine (“Using Option”)
End Sub
End Module


Written by Sandeep Mogulla, Webmaster at www.startvbdotnet.com

Index

 
Printer friendly version of the FAQ-VBNET-Option-Statement page


Sponsored links

Build IT Knowledge with Current & Trusted Content
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.
Check Out IT Certification Preparation Materials
Sign Up With SkillSoft & Get Access to Training Materials for Over 50 Professional Certifications.
Villanova University Six Sigma & IT Certificate Programs
100% Online programs in Six Sigma, IS Security, CISSP Prep, Business Analysis, Proj. Mgmt. and more!
SFTP components for .NET
Add complete SSH and SFTP support to your .NET framework application
3 Months Free - ASP.NET Web Hosting
3 Months Free & No Setup Fees on ASP.NET 3.5/2.0 Hosting on Windows 2008/2003 Servers ? Click Here!

Advertisement



Free Magazine

Free Magazines
eWeek The essential technology information source for builders of e-business.... subscribe now

Newsletter | Submit Content | About | Advertising | Awards | Contact Us | Link to us |
© 1996-2008 Community Networks Ltd All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Synchron Data - .NET development.