The Debug Print Statement

We've already established that the ? character is short for Debug.Print. It's easy to use both of these statements directly in the Immediate window; however, that's not the only place you can use this statement. Consider the following code:

Sub FunWithStringsAndNumbers() Dim strBikes As String Dim strCost As String Dim strCustomerName As String Dim intBikes As Integer Dim curCost As Currency strBikes = "5" strCost = "100"

strCustomerName = "The ""W"" Hotel, New York City" intBikes = 5 curCost = 100

Debug.Print strBikes + strCost Debug.Print intBikes + curCost Debug.Print strCustomerName End Sub

This code produces the following results in the Immediate window:

5100 105

The "W" Hotel, New York City

You can use the Debug.Print statement within any procedure to display results of calculations or values of variables in the Immediate window.

Was this article helpful?

0 0

Post a comment