Use the Immediate window of the Visual Basic Editor while working with Visual Basic

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Use the Immediate window of the Visual Basic Editor to check the results of a line of Visual Basic code. You can use the Immediate window to check the value of a control, field, or property; to display the result of an expression; or to assign a new value to a variable, field, column, or property. The Immediate window is a kind of scratchpad window in which statements, methods, and Sub procedures are evaluated immediately.

  1. If you want to use the Immediate window at a certain point during execution of the code, suspend execution at that point.

    How?

  2. Click Immediate Window on the Debug toolbar.

  3. Type a statement, method, Function, or Sub procedure call in the window, and then press ENTER.

Tips

  • You can view the results of an expression in the Immediate window by entering the Print method of the Debug object, followed by the expression. You can use a question mark (?) as shorthand for the Print method. For example, Microsoft Visual Basic displays the value returned by the FirstOfNextMonth custom function if you type either of the following lines in the Immediate window:

    Debug.Print FirstOfNextMonth()
    
    ? FirstOfNextMonth()
    

    You can also add the Print method of the Debug object to your Visual Basic code to display values or the results of expressions in the Immediate window while the code is running. When the code has finished running, you can look at the results.

  • You can display the Immediate window at any time in Microsoft Access by pressing CTRL+G.