Option Statements

Visual Basic 6 supported several Option statements:

  • Option Explicit required the programmer to declare all variables.

  • Option Base [0|1] redesignated the lower bound index of arrays.

  • Option Compare [Binary|Text|Database] indicated the default behavior of string comparisons.

  • Option Private indicated that module code was private to the hosting application.

A few of these option statements made it to Visual Basic .NET, but Option Base didn't.

Option Explicit

Option Explicit was carried over into Visual Basic .NET. You can set the project level Option Explicit mode to On or Off for the project in the Build view of the Property Pages and override it locally in the module.

The default value at the project level is Option Explicit On

Get Visual Basic® .NET Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.