7.10. Option Strict and Data-Type Conversions

Visual Basic provides several options for controlling the way the compiler handles types. These options can help you eliminate such errors as those caused by narrowing conversions. The first option is Option Explicit, which is set to On by default—it has been enabled in the programs we created in Chapters 26. Option Explicit forces you to explicitly declare all variables before they are used in a program. Forcing explicit declarations eliminates various errors. For example, when Option Explicit is set to Off, the compiler interprets misspelled variable names as new variables and implicitly declares them to be of type Object. (Class Object is the base type of all types in Visual Basic. We will discuss ...

Get Visual Basic 2005 for Programmers: Deitel Developer Series, Second Edition 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.