Skip to content

Commit acc594e

Browse files
authored
Merge pull request #3620 from gewarren/immed-window
Improvements to Immediate window article
2 parents 92b4b9b + 7f2b7ef commit acc594e

File tree

1 file changed

+44
-35
lines changed

1 file changed

+44
-35
lines changed

docs/ide/reference/immediate-window.md

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,38 @@ manager: douge
1818
ms.workload:
1919
- "multiple"
2020
---
21-
# Immediate Window
22-
The **Immediate** window is used to debug and evaluate expressions, execute statements, print variable values, and so forth. It allows you to enter expressions to be evaluated or executed by the development language during debugging. To display the **Immediate** window, open a project for editing, then choose **Windows** from the **Debug** menu and select **Immediate**, or press CTRL+ALT+I.
21+
# Immediate window
2322

24-
You can use this window to issue individual [!INCLUDE[vsprvs](../../code-quality/includes/vsprvs_md.md)] commands. The available commands include `EvaluateStatement`, which can be used to assign values to variables. The **Immediate** window also supports IntelliSense.
23+
The **Immediate** window is used to debug and evaluate expressions, execute statements, print variable values, and so forth. It allows you to enter expressions to be evaluated or executed by the development language during debugging.
2524

26-
## Displaying the Values of Variables
27-
This window can be particularly useful while debugging an application. For example, to check the value of a variable `varA`, you can use the [Print Command](../../ide/reference/print-command.md):
25+
To display the **Immediate** window, open a project for editing, and then choose **Debug** > **Windows** > **Immediate** or press **Ctrl**+**Alt**+**I**. You can also enter **Debug.Immediate** in the **Command** window.
26+
27+
You can use the **Immediate** window to issue individual Visual Studio commands. The available commands include `EvaluateStatement`, which can be used to assign values to variables. The **Immediate** window also supports IntelliSense.
28+
29+
## Display the values of variables
30+
31+
The **Immediate** window can be particularly useful while debugging an application. For example, to check the value of a variable `varA`, you can use the [Print Command](../../ide/reference/print-command.md):
2832

2933
```cmd
3034
>Debug.Print varA
3135
```
3236

33-
The question mark (?) is an alias for `Debug.Print`, so this command can also be written:
37+
The question mark (?) is an alias for `Debug.Print`, so this command can also be written:
3438

3539
```cmd
3640
>? varA
3741
```
3842

39-
Both versions of this command will return the value of the variable `varA`.
43+
Both versions of this command return the value of the variable `varA`.
4044

41-
> [!NOTE]
42-
> To issue a [!INCLUDE[vsprvs](../../code-quality/includes/vsprvs_md.md)] command in the **Immediate** window, you must preface the command with a greater than sign (>). To enter multiple commands, switch to the **Command** window.
45+
> [!TIP]
46+
> To issue a Visual Studio command in the **Immediate** window, you must preface the command with a greater than sign (>). To enter multiple commands, switch to the **Command** window.
4347
48+
## Design-time expression evaluation
4449

45-
## Design Time Expression Evaluation
46-
You can use the **Immediate** window to execute a function or subroutine at design time.
50+
You can use the **Immediate** window to execute a function or subroutine at design time.
4751

48-
#### To execute a function at design time
52+
### Execute a function at design time
4953

5054
1. Copy the following code into a [!INCLUDE[vbprvb](../../code-quality/includes/vbprvb_md.md)] console application:
5155

@@ -65,19 +69,21 @@ The **Immediate** window is used to debug and evaluate expressions, execute stat
6569

6670
2. On the **Debug** menu, click **Windows**, and then click **Immediate**.
6771

68-
3. Type `?MyFunction(2)` in the **Immediate** window and press Enter.
72+
3. Type `?MyFunction(2)` in the **Immediate** window and press **Enter**.
6973

70-
The **Immediate** window will run `MyFunction` and display `4`.
74+
The **Immediate** window runs `MyFunction` and displays `4`.
7175

72-
If the function or subroutine contains a breakpoint, [!INCLUDE[vsprvs](../../code-quality/includes/vsprvs_md.md)] will break execution at the appropriate point. You can then use the debugger windows to examine your program state. For more information see [Walkthrough: Debugging at Design Time](../../debugger/walkthrough-debugging-at-design-time.md).
76+
If the function or subroutine contains a breakpoint, Visual Studio breaks execution at the appropriate point. You can then use the debugger windows to examine your program state. For more information see [Walkthrough: Debugging at Design Time](../../debugger/walkthrough-debugging-at-design-time.md).
7377

7478
You cannot use design time expression evaluation in project types that require starting up an execution environment, including [!INCLUDE[trprVSTOshort](../../ide/reference/includes/trprvstoshort_md.md)] projects, web projects, Smart Device projects, and SQL projects.
7579

76-
### Design Time Expression Evaluation in Multi-Project Solutions
77-
When establishing the context for design time expression evaluation, [!INCLUDE[vsprvs](../../code-quality/includes/vsprvs_md.md)] references the currently selected project in Solution Explorer. If no project is selected in Solution Explorer, [!INCLUDE[vsprvs](../../code-quality/includes/vsprvs_md.md)] attempts to evaluate the function against the startup project. If the function cannot be evaluated in the current context, you will receive an error message. If you are attempting to evaluate a function in a project that is not the startup project for the solution and you receive an error, try selecting the project in Solution Explorer and attempt the evaluation again.
80+
### Design-time expression evaluation in multi-project solutions
81+
82+
When establishing the context for design time expression evaluation, Visual Studio references the currently selected project in Solution Explorer. If no project is selected in Solution Explorer, Visual Studio attempts to evaluate the function against the startup project. If the function cannot be evaluated in the current context, you will receive an error message. If you are attempting to evaluate a function in a project that is not the startup project for the solution and you receive an error, try selecting the project in Solution Explorer and attempt the evaluation again.
7883

79-
## Entering Commands
80-
You must enter the greater than sign (>) when issuing [!INCLUDE[vsprvs](../../code-quality/includes/vsprvs_md.md)] commands in the **Immediate** window. Use the UP ARROW and DOWN ARROW keys to scroll through previously issued commands.
84+
## Enter commands
85+
86+
Enter the greater than sign (>) when issuing Visual Studio commands in the **Immediate** window. Use the **Up arrow** and **Down arrow** keys to scroll through previously issued commands.
8187

8288
|Task|Solution|Example|
8389
|----------|--------------|-------------|
@@ -86,42 +92,45 @@ You cannot use design time expression evaluation in project types that require s
8692
|Switch to the Command window.|Enter `cmd` into the window, prefacing it with a greater than sign (>).|`>cmd`|
8793
|Switch back to the Immediate window.|Enter `immed` into the window without the greater than sign (>).|`immed`|
8894

89-
## Mark Mode
90-
When you click on any previous line in the **Immediate** window, you shift automatically into Mark mode. This allows you to select, edit, and copy the text of previous commands as you would in any text editor, and paste them into the current line.
95+
## Mark mode
96+
97+
When you click on any previous line in the **Immediate** window, you shift automatically into Mark mode. This allows you to select, edit, and copy the text of previous commands as you would in any text editor, and paste them into the current line.
9198

92-
## The Equals (=) Sign
93-
The window used to enter the `EvaluateStatement` command determines whether an equals sign (=) is interpreted as a comparison operator or as an assignment operator.
99+
## The equals sign(=)
94100

95-
In the **Immediate** window, an equals sign (=) is interpreted as an assignment operator. So, for example, the command
101+
The window used to enter the `EvaluateStatement` command determines whether an equals sign (=) is interpreted as a comparison operator or as an assignment operator.
102+
103+
In the **Immediate** window, an equals sign (=) is interpreted as an assignment operator. So, for example, the command
96104

97105
```cmd
98106
>Debug.EvaluateStatement(varA=varB)
99107
```
100108

101-
will assign to variable `varA` the value of variable `varB`.
109+
assigns the value of variable `varB` to variable `varA`.
102110

103-
In the **Command** window, by contrast, an equals sign (=) is interpreted as a comparison operator. You cannot use assignment operations in the **Command** window. So, for example, if the values of variables `varA` and `varB` are different, then the command
111+
In the **Command** window, by contrast, an equals sign (=) is interpreted as a comparison operator. You cannot use assignment operations in the **Command** window. So, for example, if the values of variables `varA` and `varB` are different, then the command
104112

105113
```cmd
106114
>Debug.EvaluateStatement(varA=varB)
107115
```
108116

109-
will return a value of `False`.
117+
returns a value of `False`.
118+
119+
## First-chance exception notifications
110120

111-
## First-Chance Exception Notifications
112-
In some settings configurations, first-chance exception notifications are displayed in the **Immediate** window.
121+
In some settings configurations, first-chance exception notifications are displayed in the **Immediate** window.
113122

114-
#### To toggle first-chance exception notifications in the Immediate window
123+
### Toggle first-chance exception notifications in the Immediate window
115124

116-
1. On the **View** menu, click **Other Windows**, and click **Output**.
125+
1. On the **View** menu, click **Other Windows**, and click **Output**.
117126

118-
2. Right-click on the text area of the **Output** window, and select or deselect **Exception Messages**.
127+
2. Right-click on the text area of the **Output** window, and then select or deselect **Exception Messages**.
119128

120-
## See Also
129+
## See also
121130

122131
- [Navigating through Code with the Debugger](../../debugger/navigating-through-code-with-the-debugger.md)
123132
- [Command Window](../../ide/reference/command-window.md)
124-
- [First look at the debugger](../../debugger/debugger-feature-tour.md)
133+
- [First look at the debugger](../../debugger/debugger-feature-tour.md)
125134
- [Walkthrough: Debugging at Design Time](../../debugger/walkthrough-debugging-at-design-time.md)
126135
- [Visual Studio Command Aliases](../../ide/reference/visual-studio-command-aliases.md)
127-
- [Using Regular Expressions in Visual Studio](../../ide/using-regular-expressions-in-visual-studio.md)
136+
- [Using Regular Expressions in Visual Studio](../../ide/using-regular-expressions-in-visual-studio.md)

0 commit comments

Comments
 (0)