Saturday 31 January 2009

A Visual Basic Annoyance - Option Strict Off By Default

In Microsoft's .NET environment I normally program in C#. But occasionally I am asked to do Visual Basic development.  Visual Basic has a project property known as option strict. This is set off by default. Unfortunately, I usually forget to set it to on. When I eventually remember I update the global environment setting to make on the default for new projects. However, when developing, I usually have one or two test projects on the side for trying things out before incorporating them in my main project. This was exactly the situation I found myself  in recently.  I had created some test projects but, unknown to me , some of them were created before I remembered to change the global environment setting, so they still had option strict off. So I merrily tried out my ideas and then copied and pasted them back into my main project, which had option strict on, to find they didn't compile. Why didn't Microsoft make option strict on the default?