Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I set Option Explicit and Option Strict on a Project/Solution level?

I really like the coding speed that VB.NET provides, but I don't like the possibility to forget to declare variable types, return types of functions, etc. and that is why in each class I use:

Option Explicit On  
Option Strict On

Is there a way to define those two options on the project/solution level?
It is really tedious to copy those two options in each class...
We code with Visual Studio 2010 in .NET 4 Client Profile.

like image 831
This is it Avatar asked Feb 22 '11 10:02

This is it


2 Answers

Yes, you can set these options for the entire project in your project's Properties:

  1. Right-click on your project in the Solution Explorer, and select "Properties" from the context menu.
  2. Click on the "Compile" tab in the list on the left-hand side.
  3. Set the values of the comboboxes as desired.

   Project properties - Compile tab - Compile Options


You could also choose to specify these settings globally in the Visual Studio options (although this will only affect new projects, not existing ones):

  1. In the Visual Studio environment, click on the "Tools" menu and select "Options".
  2. Expand the "Projects and Solutions" item in the treeview on the left-hand side of the dialog.
  3. Select the "VB Defaults" item.
  4. Set your "Default project settings" as desired.

   VS Options - Projects and Solutions - VB Defaults - Default project settings

like image 107
Cody Gray Avatar answered Oct 05 '22 13:10

Cody Gray


Well, the obvious place is to look in the project options dialog, and lo and behold:

Visual Basic .NET Project Options

like image 38
Lasse V. Karlsen Avatar answered Oct 05 '22 13:10

Lasse V. Karlsen