You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ide/reference/immediate-window.md
+44-35Lines changed: 44 additions & 35 deletions
Original file line number
Diff line number
Diff line change
@@ -18,34 +18,38 @@ manager: douge
18
18
ms.workload:
19
19
- "multiple"
20
20
---
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
23
22
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.
25
24
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):
28
32
29
33
```cmd
30
34
>Debug.Print varA
31
35
```
32
36
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:
34
38
35
39
```cmd
36
40
>? varA
37
41
```
38
42
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`.
40
44
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.
43
47
48
+
## Design-time expression evaluation
44
49
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.
47
51
48
-
#### To execute a function at design time
52
+
###Execute a function at design time
49
53
50
54
1. Copy the following code into a [!INCLUDE[vbprvb](../../code-quality/includes/vbprvb_md.md)] console application:
51
55
@@ -65,19 +69,21 @@ The **Immediate** window is used to debug and evaluate expressions, execute stat
65
69
66
70
2. On the **Debug** menu, click **Windows**, and then click **Immediate**.
67
71
68
-
3. Type `?MyFunction(2)` in the **Immediate** window and press Enter.
72
+
3. Type `?MyFunction(2)` in the **Immediate** window and press **Enter**.
69
73
70
-
The **Immediate** window will run `MyFunction` and display`4`.
74
+
The **Immediate** window runs `MyFunction` and displays`4`.
71
75
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).
73
77
74
78
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.
75
79
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.
78
83
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.
81
87
82
88
|Task|Solution|Example|
83
89
|----------|--------------|-------------|
@@ -86,42 +92,45 @@ You cannot use design time expression evaluation in project types that require s
86
92
|Switch to the Command window.|Enter `cmd` into the window, prefacing it with a greater than sign (>).|`>cmd`|
87
93
|Switch back to the Immediate window.|Enter `immed` into the window without the greater than sign (>).|`immed`|
88
94
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.
91
98
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(=)
94
100
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
96
104
97
105
```cmd
98
106
>Debug.EvaluateStatement(varA=varB)
99
107
```
100
108
101
-
will assign to variable `varA` the value of variable `varB`.
109
+
assigns the value of variable `varB` to variable `varA`.
102
110
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
104
112
105
113
```cmd
106
114
>Debug.EvaluateStatement(varA=varB)
107
115
```
108
116
109
-
will return a value of `False`.
117
+
returns a value of `False`.
118
+
119
+
## First-chance exception notifications
110
120
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.
113
122
114
-
#### To toggle first-chance exception notifications in the Immediate window
123
+
###Toggle first-chance exception notifications in the Immediate window
115
124
116
-
1.On the **View** menu, click **Other Windows**, and click **Output**.
125
+
1. On the **View** menu, click **Other Windows**, and click **Output**.
117
126
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**.
119
128
120
-
## See Also
129
+
## See also
121
130
122
131
-[Navigating through Code with the Debugger](../../debugger/navigating-through-code-with-the-debugger.md)
0 commit comments