Value of Variables Reset in Immediate Pane

Last reviewed: July 29, 1997
Article ID: Q111668
The information in this article applies to:
  • Microsoft Visual Basic Programming System, Applications Edition, version 1.0

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          : kberrmsg kbprg
Version           : 1.00
Platform          : WINDOWS


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 29, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.