Datasheet

Finally, note that IntelliSense is based on your editing context. While editing a fi le, you may reach a point
where you are looking for a speci c item to show up in IntelliSense but when you repeatedly type slightly
different versions, nothing appears. IntelliSense recognizes that you aren t in a method or you are outside of
the scope of a class, so it removes items that are inappropriate for the current location in your source code
from the list of items available from IntelliSense.
Code Expansion
Going beyond IntelliSense is code expansion. Code expansion recognizes that certain keywords are
consistently associated with other lines of code. At the most basic level, this occurs when you declare a new
Function or Sub : Visual Studio automatically inserts the End Sub or End Function line once you press
Enter. Essentially, Visual Studio is expanding the declaration line to include its matching endpoint.
However, true code expansion goes further than this. With true code expansion, you can type a keyword
such as
For , ForEach , Select , or any of a number of Visual Basic keywords. If you then use the Tab key,
Visual Studio will attempt to recognize that keyword and insert the block of code that you would otherwise
need to remember and type yourself. For example, instead of needing to remember how to format the
control values of a Select statement, you can just type this fi rst part of the command and then press Tab to
get the following code block:
Select Case VariableName
Case 1
Case 2
Case Else
End Select
Unfortunately, this is a case where just showing you the code isn t enough. That s because the code that is inserted
has active regions within it that represent key items you will customize. Thus, Figure 1 - 18 provides a better
representation of what is inserted when you expand the Select keyword into a full Select Case statement.
FIGURE 1 - 18
When the block is inserted, the editor automatically positions your cursor in the fi rst highlighted block
VariableName . When you start typing the name of the variable that applies, the editor automatically clears that
Project ProVB_VS2010
35
CH001.indd 35CH001.indd 35 4/5/10 11:56:50 AM4/5/10 11:56:50 AM