Option Explicit and Option Strict


When Option Explicit is on, you must explicitly declare all variables before using them. When Option Explicit is off, Visual Basic creates a variable the first time it is encountered if is has not yet been declared. To make your code easier to understand, and to avoid problems such as Visual Basic creating a new variable because of a typographical error, you should always turn Option Explicit on.

When Option Strict is on, Visual Basic will not implicitly perform narrowing type conversions. For example, if you set an Integer variable equal to a String value, Visual Basic will raise an error because the String might not contain an Integer value. When Option Strict is off, Visual Basic will silently attempt narrowing conversions. It tries to convert the String value into an Integer and raises an error if the String doesn’t contain an integral value. To avoid confusion and potentially slow conversions, always turn Option Strict on.




Visual Basic 2005 with  .NET 3.0 Programmer's Reference
Visual Basic 2005 with .NET 3.0 Programmer's Reference
ISBN: 470137053
EAN: N/A
Year: 2007
Pages: 417

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net