Knowledge Base

Value of Variables Reset in Immediate Pane

PSS ID Number: 111668

Article Last Modified on 1/17/2001


The information in this article applies to:


This article was previously published under Q111668

SUMMARY

In a Visual Basic module, when you bring up the Debug window in the middle of a procedure and dimension a variable in the Immediate pane as a user- defined type, if you return the value of any variable defined in the procedure by typing the variable name in the Immediate pane, you receive the following error message:
User-defined type not defined
Note that the values of the variables are reset only when you return the value in the Immediate pane. The values are still available when you continue running the procedure.

MORE INFORMATION

Usually, when you define a variable using the Dim statement in a procedure, the defined value exists until the procedure is finished running. You can use the Immediate pane in the Debug window while a procedure is running to return the current value of a variable by typing the following statement in the Immediate pane and pressing ENTER:

?<varname>

where <varname> is the name of the variable.

To bring up the Debug window while a procedure is running, you can use the Stop statement or set a Breakpoint in your procedure.

A user-defined data type is any data type that you define using the Type statement. A user-defined data type can contain one or more variables of different types. As an example, to define the user-defined data type PHONE containing the variable AREA of Integer data type, use the following syntax at the top of your module:
   Type Phone

      Area as Integer

   End Type
				
The following is an example of a statement that declares the variable X as the user-defined data type PHONE:
   Dim X as Phone
				
If you type this statement in the Immediate pane, you receive the following error message:
Invalid in Immediate pane
Additionally, if a procedure is running when you type this statement in the Immediate pane, you cannot return the value of any variable defined in your procedure by typing the name of the variable in the Immediate pane. You must run the procedure again to return the correct value of your variable by typing it in the Immediate pane.

REFERENCES

For more information about user-defined data types or a data type summary, choose the Search button in the Visual Basic Reference and type:

user-defined type

For more information about the Type statement, choose the Search button in the Visual Basic Reference and type:

type

Keywords: KB111668
Technology: kbVBA100 kbVBASearch kbZNotKeyword3 kbZNotKeyword6