Working with the VB IDE – Part 2

Customizing the VB IDE


In general, customizing the VB environment can be done by clicking Tools on the VB menu bar, then selecting Options.



This causes the tabbed dialog box shown below  to be displayed. Each of the tabs of the Options dialog box will be discussed in turn.




The Editor Tab


The Editor tab of the Options dialog box (shown above), make sure Require Variable Declaration is checked (the VB default is unchecked).  This is the only setting change I strongly recommend that everybody make. Checking this option forces VB to place a line of code reading "Option Explicit" at the beginning of each new module, which in turn forces you to explicitly declare all your variables, just like you have to do in most other languages such as C/C++, Java, COBOL, Pascal, etc.  Leaving this option unchecked lets you revert back to the "old days" of BASIC, where you don't declare variables, but simply use them "on the fly"; this is considered poor programming practice.


I would leave all other items on the Editor tab checked, with maybe the exception of Auto Syntax Check.  Whenever you are coding and you move your cursor off of a line that contains a syntax error, the text on that line changes color to red, and – if Auto Syntax Check is in effect – a message box with a cryptic error message pops up, and then you have to click the OK button to get rid of the box and continue coding.  Over the years I had come to find this annoying, because the red color already tells me that I have a problem; I don't need it to "talk to me" too.


My preference for Tab Width is 4.



The Editor Format Tab


The only thing I change on the Editor Format tab (shown below) is the Font.  The default font for the editor is Courier, which is fine, but I'm partial to FixedSys. Courier and FixedSys are two of the very few monospaced fonts available.  I strongly recommend using a monospaced, as opposed to a proportional, font for typing code. Monospaced and proportional fonts are contrasted below:


This is Courier, a monospaced font, which is a font where every character takes up the same amount of space. A monospaced font should be used for writing code.


This is Times New Roman, a proportional font, which is a font in which letters and other characters vary in size. For example, the letters "M" and "W" are much wider than the letters "i" and "l".  A proportional font is standard for most documents.




The General tab


On the General tab (shown below) I change the Width and Height of the Grid Units each to 60 (the default is 120).  This setting has to do with the spacing of the dots on the form at design-time.  The dots on the form act as a guide when you are placing elements on the form to design your GUI (these dots are not visible when your program runs).  Changing these settings to 60 to allow a finer degree of control when designing forms.




The Docking Tab


The Docking tab (shown below) is where you specify which windows in the IDE you would like to able to "dock". As I mentioned earlier, this "docking" is a pet peeve of mine, so I clear (uncheck) all of the boxes on this tab, so that each window floats independently on my Windows desktop as I work with VB.


Note: Due to a quirk in VB, the docking options do not "take" the first time that you change them.  After changing the docking the options, when you restart VB, you must go to the docking tab once again, and redo your changes. The changes should remain in place after that.




The Environment Tab


On the Environment tab (shown below), under "When a program starts", I recommend checking "Prompt to save changes".  This causes your coding changes to be saved before the program runs.  If you leave the default option "Don't save changes" and your program "crashes" when it runs, you could lose a lot of work.  Also, the options under "When Visual Basic starts" control whether or not you see that initial "New Project" dialog box.




The Advanced Tab


It is on the Advanced tab (shown below) that you specify whether or not you want the SDI (Single Document Interface) development environment.  As I mentioned earlier, this is the development environment I prefer, so I always check that box.  The SDI environment allows you to move a form and other windows freely about on the desktop while you are designing, whereas the default "MDI" environment boxes a form in, which I find confining.  (When you switch from MDI to SDI or vice-versa, VB will display a message box indicating that the change will go into effect the next time you start VB.  If you want the change to be effective immediately, you must stop VB then restart it.)



Once you have set all of the desired options on all tabs of the Options dialog box, click OK.  If you changed from the MDI to the SDI development environment (or vice-versa), the following message appears:



To have the change take effect, close VB, then restart VB. Recall that, due to a glitch in VB, you must also redo your "docking" changes to have those take effect.