The Immediate window is an object you can use to test
functions and expressions. It is available only in Visual Basic (and not
in the Microsoft Access side). To ("physically") use the
Immediate window, on the main menu of Microsoft Visual Basic, you can
click View -> Immediate Window. It's a habit to keep the Immediate
window in the bottom section of the Code Editor but you can move it from
there by dragging its title bar:
Probably the simplest action you can perform in the
Immediate window consists of testing an expression. For example, you can
write an arithmetic operation an examine its result. To do this, in the
Immediate window, type the question mark "?" followed by the
expression and press Enter. Here is an example that tests the result of 275.85 + 88.26:
One of the most basic actions you can perform in the
Immediate window consists of testing a built-in function. To do this, type
? following by the name of the function and its arguments, if any. For
example, to test the UCase$ function we reviewed in Lesson 5, in the
Immediate window, you could type:
? UCase("République d'Afrique du Sud")
After type the function, press Enter. The result would
display in the next line:

The
Immediate window is recognized in code as the Debug object. To
programmatically something, such as a string, in the Immediate window, the
Debug object provides the Print method. The simplest way to use it
consist of passing it a string. For example, imagine you create a button
on a form, you name it cmdTestFullName and initialize it with a string.
Here is an example of how you can display that string in the Immediate
window:
Private Sub cmdTestFullName_Click()
Dim strFullName$
strFullName$ = "Daniel Ambassa"
Debug.Print strFullName$
End Sub
When you click the button, the Immediate window would
display the passed string:
In the same way, you can create a more elaborate
expression and test its value in the Immediate window:
You can also pass a value, such as a date, that can
easily be converted to a string. |