ARCHITECTURAL TOOLS

The code editor provides several powerful tools that can help you understand the structure of your code and how to navigate through its pieces. They can give you a better understanding of how the pieces of the program fit together, and they can help you track down important code snippets, such as where a variable or type is defined and where one piece of code is called by others.

The following sections describe the most useful of these kinds of architectural tools and explain how to invoke them.

Rename

If you right-click the definition or occurrence of a symbol, such as a variable, subroutine, function, or class, and select Rename, Visual Studio displays a dialog box where you can enter a new name for the item. If you enter a name and click OK, Visual Studio updates all references to that symbol. If the symbol is a variable, it changes all references to the variable so they use the new name.

This is much safer than using a simple textual find-and-replace, which can wreak havoc with strings that contain your target string. For example, if you textually replace the variable name factor with issue, your Factorial function becomes Issueial. In contrast, if you right-click the factor variable, select Rename, and set the new name to issue, Visual Studio only updates references to the variable.

CORRUPTED COMMENTS
Unfortunately, Rename still leaves any comments that discuss the factor variable unchanged. You’ll have to search the comments to fix them.

Go To ...

Get Visual Basic 2012 Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.