Datasheet
One particularly useful command is Tools.Alias. This command lists command aliases defined by
the IDE. For example, it indicates that
? is the alias for Debug.Print and that ?? is the alias for Debug
.QuickWatch
.
The Command window includes some IntelliSense support. If you type the name of a menu, for exam-
ple Debug or Tools, IntelliSense will display the commands available within that menu.
While the Command window issues commands to the IDE, the Immediate window executes Visual Basic
statements. For example, suppose that you have written a subroutine named
CheckPrinter. Then the
following statement in the Immediate window executes that subroutine.
CheckPrinter
Executing subroutines in the Immediate window lets you quickly and easily test routines without writ-
ing user interface code to handle all possible situations. You can call a subroutine or function, passing it
different parameters to see what happens. If you set breakpoints within the routine, the debugger will
pause there.
Similarly, you can also set the values of global variables and then call routines that use them. The follow-
ing Immediate window commands set the value of the
m_PrinterName variable and then calls the
CheckPrinter subroutine.
m_PrinterName = “LP_REMOTE”
CheckPrinter
You can execute much more complex statements in the Command and Immediate windows. For exam-
ple, suppose that your program uses the following statement to open a file for reading.
Dim fs As FileStream = File.OpenRead( _
“C:\Program Files\Customer Orders\Summary” & _
datetime.Now().ToString(“yymmdd”) & “.dat”)
Suppose that the program is failing because some other part of the program is deleting the file. You can
type the following code (all on one line) into the Immediate window to see if the file exists. As you step
through different pieces of the code, you can use this statement again to see if the file has been deleted.
?System.IO.File.Exists(“C:\Program Files\Customer Orders\Summary” & _
DateTime.Now().ToString(“yymmdd”) & “.dat”)
The window evaluates the complicated string expression to produce a file name. It then uses the
System.IO.File.Exists command to determine whether the file exists and displays True or False
accordingly.
Data
The Data menu, shown in Figure 1-36, contains commands that deal with data and data sources. Some of
the commands in this menu are only visible and enabled if you are designing a form and that form con-
tains the proper data objects.
33
IDE
571982 ch01_2.qxd 1/19/06 1:15 PM Page 33