On last.fm: Check Out Duffy's Music, Videos, & Pics

Brush up on option statements in VB.NET

Tags: Microsoft development tools, .NET, Programming languages, Irina Medvinskaya, Microsoft Visual Basic.Net, option statement, Option Compare, Option Strict, Option Explicit, Visual Basic Tips Newsletter

  • Save
  • Print
  • Recommend
  • 1

Takeaway: In this tip, Irina Medvinskaya looks at the three option statements that are supported in VB.NET: Option Explicit, Option Compare, and Option Strict.

If you want to properly utilize VB.NET, it is very important to understand option statements. The following is a quick overview of the three option statements that are supported in VB.NET:

  • Option Explicit: By default, Option Explicit is on for VB.NET projects. It's a good programming practice to set Option Explicit on because it helps developers avoid implicitly declaring variables, and thus write better code. This forces developers to explicitly declare variables utilizing the Dim keyword and specifying the datatype for the variable.
  • Option Compare: By default, the Option Compare is Binary; however, you can set Option Compare to Text instead.
  • Option Strict: Option Strict Off is the default mode for the code in VB.NET; however, it's preferable to write code with Option Strict on. Option Strict On prevents implicit type conversions by the compiler. It's also a safer way to develop code, which is why most developers prefer it.

Note: Option Base, which allows you to specify the base of the declared arrays, is supported in VB6 but not in VB.NET.

Miss a tip?

Check out the Visual Basic archive, and catch up on the most recent editions of Irina Medvinskaya's column.

Advance your scripting skills to the next level with TechRepublic's free Visual Basic newsletter, delivered each Friday. Automatically sign up today!

  • Save
  • Print
  • Recommend
  • 1

Print/View all Posts Comments on this article

Needs More Detail jetter | 11/10/06
Good Point TomMerritt | 11/10/06
Option Compare siva@... | 11/11/06

What do you think?

Article Categories

Security
Security Solutions, IT Locksmith
Networking and Communications
E-mail Administration NetNote, Cisco Routers and Switches
CIO and IT Management
Project Management, CIO Issues, Strategies that Scale
Desktops, Laptops & OS
Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
Data Management
Oracle, SQL Server
Servers
Windows NT, Linux NetNote, Windows Server 2003
Career Development
Geek Trivia
Software/Web Development
Web Development Zone, Visual Basic, .NET
advertisement
Click Here