What do Option Strict and Option Explicit do?

Option Explicit means that all variables must be declared. See here. Without this, you can accidentally declare a new variable just by misspelling another variable name. This is one of those things that cause a lot of grief as you’re trying to debug VB programs and figure out why your program isn’t working properly. In my opinion, this shouldn’t even be an option – it should always be on.

Option Strict “restricts implicit data type conversions to only widening conversions”. See here. With this option enabled, you can’t accidentally convert one data type to another that is less precise (e.g. from an Integer to a Byte). Again, an option that should be turned on by default.

Leave a Comment