Saturday, January 8, 2011

Debugging & Immediate Mode, Command Window

The Immediate mode of the Command window is used for debugging purposes such as evaluating expressions, executing statements, printing variable values, and so forth. It allows you to enter expressions to be evaluated or executed by the development language during debugging. In some cases, you can change the value of variables. The Immediate mode now also supports Intellisense.
You can also temporarily issue Visual Studio .NET commands in Immediate mode. This can be useful if you are debugging an application and using Immediate mode to view or change the value of variables but still want to interact with the interactive development environment (IDE) using commands.
Note   To issue a single Visual Studio .NET command while in Immediate mode, you must preface the command with a greater than sign (>). For example, to switch to Command mode from Immediate mode, you must preface the command with a greater than sign (>). To enter multiple commands, switch to Command mode.
Once in a project, the Command window can be opened in Immediate mode by pressing CTRL+ALT+I, or by choosing Immediate on the Windowssubmenu of the Debug menu. When the Command window is in Immediate mode, the title bar displays the text Command Window - Immediate.
In Command mode, statements separated by the equal sign (=) are evaluated as comparison operators. For example, if the value of variables aand b are different, then >? a = b returns a value of False. In Immediate mode, however, the statement a=b is evaluated as an assignment operation rather than a comparison operation. That is, a=b assigns the value of variable a to the value of variable b. You cannot use assignment operations in Command mode.
Unlike previous versions of the Immediate window, the UP ARROW and DOWN ARROW keys do not move the cursor to previous commands, but rather allow you to scroll through previously issued commands.

Note   Commands typed in Command mode are not prefaced by the greater than sign (>) because it is the command prompt in that mode. You must enter the greater than sign (>), however, when issuing Visual Studio .NET commands while in Immediate mode.


Immediate Window

You can use the immediate window in VB to get the current values of variables and to run other code. To show it click View | Immediate. You can only use the immediate window when code execution is paused.
 
Immediate Window
Entering a ? and then the variable name or property will return its value, press RETURN to execute the query. The text below will return the path of your application, the text in italics is a possible result. Values in Italics are return results.
? App.Path
C:AppPathApp.EXE
The following example will return the value of the caption property:
? Label1.Caption
&Cancel
or perform calulations using variables or just numbers:
? Text1 * 10
198
? 100 / 1.92
52.0833333333333
You can also run one line or multiple statements. For example:
frmMain.Visible = False
To enter multiple lines of code, without it executing immediately press CTRL+Return
Below are a few examples
' This will return the number of Forms loaded into the memory
? Forms.Count
' This will return the name of Form(0) which is stored in the memory
? Forms(0).Name
' This will display a message box
Msgbox "hello"





No comments :

Post a Comment