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/immediate-window.md
+32-11Lines changed: 32 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Use the Immediate Window
3
3
description: Learn how to use the Immediate window to debug and evaluate expressions, execute statements, and print variable values.
4
-
ms.date: 02/25/2019
4
+
ms.date: 08/05/2025
5
5
ms.topic: how-to
6
6
dev_langs:
7
7
- VB
@@ -18,21 +18,25 @@ ms.subservice: general-ide
18
18
---
19
19
# Use the Immediate window
20
20
21
-
Use the **Immediate** window to debug and evaluate expressions, execute statements, and print variable values. The **Immediate** window evaluates expressions by building and using the currently selected project.
21
+
This article explains how to use the **Immediate** window to debug and evaluate expressions, execute statements, and print variable values. The **Immediate** window evaluates expressions by building and using the currently selected project.
22
22
23
-
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.
23
+
To display the **Immediate** window, first open a project to edit, and then choose **Debug** > **Windows** > **Immediate** or press **Ctrl**+**Alt**+**I**. You can also enter *Debug.Immediate* in the **Command** window.
24
24
25
25
The **Immediate** window supports IntelliSense.
26
26
27
27
## Display the values of variables
28
28
29
+
<<<<<<< HEAD:docs/ide/immediate-window.md
29
30
The **Immediate** window is particularly useful when you're debugging an app. For example, to check the value of a variable `varA`, you can use the [Print command](../ide/reference/print-command.md):
31
+
=======
32
+
The **Immediate** window is useful when you debug an app. For example, to check the value of a variable `varA`, you can use the [Print command](../../ide/reference/print-command.md):
The question mark (?) is an alias for `Debug.Print`, so this command can also be written:
39
+
The question mark (`?`) is an alias for `Debug.Print`, so this command can also be written:
36
40
37
41
```cmd
38
42
? varA
@@ -41,7 +45,11 @@ The question mark (?) is an alias for `Debug.Print`, so this command can also be
41
45
Both versions of this command return the value of the variable `varA`.
42
46
43
47
> [!TIP]
48
+
<<<<<<< HEAD:docs/ide/immediate-window.md
44
49
> 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](../ide/reference/command-window.md).
50
+
=======
51
+
> 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](command-window.md).
@@ -65,23 +73,27 @@ You can use the **Immediate** window to execute a function or subroutine at desi
65
73
EndModule
66
74
```
67
75
68
-
2. On the **Debug** menu, choose **Windows** > **Immediate**.
76
+
1. On the **Debug** menu, choose **Windows** > **Immediate**.
69
77
70
-
3. Type `?MyFunction(2)` in the **Immediate** window and press **Enter**.
78
+
1. Type `?MyFunction(2)` in the **Immediate** window and press **Enter**.
71
79
72
80
The **Immediate** window runs `MyFunction` and displays `4`.
73
81
82
+
<<<<<<< HEAD:docs/ide/immediate-window.md
74
83
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).
84
+
=======
85
+
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: Debug at design time](../../debugger/walkthrough-debugging-at-design-time.md).
You can't use design-time expression evaluation in project types that require starting up an execution environment, including Visual Studio Tools for Office projects, web projects, Smart Device projects, and SQL projects.
77
89
78
90
### Design-time expression evaluation in multi-project solutions
79
91
80
-
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'll receive an error message. If you're attempting to evaluate a function in a project that's not the startup project for the solution and you receive an error, try selecting the project in Solution Explorer and attempt the evaluation again.
92
+
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 can't be evaluated in the current context, you receive an error message. If you're attempting to evaluate a function in a project that's not the startup project for the solution and you receive an error, try selecting the project in Solution Explorer and attempt the evaluation again.
81
93
82
94
## Enter commands
83
95
84
-
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 your previously used commands.
96
+
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 your previously used commands.
85
97
86
98
|Task|Solution|Example|
87
99
|----------|--------------|-------------|
@@ -92,7 +104,7 @@ Enter the greater than sign (>) when issuing Visual Studio commands in the **Imm
92
104
93
105
## Mark mode
94
106
95
-
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.
107
+
When you select 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.
96
108
97
109
## Examples
98
110
@@ -118,15 +130,24 @@ In some settings configurations, first-chance exception notifications are displa
118
130
119
131
### Toggle first-chance exception notifications in the Immediate window
120
132
121
-
1. On the **View** menu, click **Other Windows**, and click**Output**.
133
+
1. On the **View** menu, select**Output**.
122
134
123
135
2. Right-click on the text area of the **Output** window, and then select or deselect **Exception Messages**.
124
136
125
-
## See also
137
+
## Related content
126
138
139
+
<<<<<<< HEAD:docs/ide/immediate-window.md
127
140
-[Navigating through Code with the Debugger](../debugger/navigating-through-code-with-the-debugger.md)
0 commit comments