WD97: Troubleshooting Variables and Data Types

Last reviewed: February 11, 1998
Article ID: Q161923
The information in this article applies to:
  • Microsoft Word 97 for Windows

SUMMARY

This article offers suggestions for using variables and data types in Microsoft Visual Basic for Applications in Microsoft Office 97.

MORE INFORMATION

When declaring variables, the default data type is Variant. Programmers should ideally specify specific data types and not use the Variant data types. Variant data types consume more memory, do not offer the same performance as specific data types, and can promote errors in programming logic.

Make sure variables are properly declared. Consider the following example:

   Dim oVar1, oVar2 As Object

This syntax may appear to be declaring two Object variables, but in this case oVar1 is being implicitly declared as a Variant (the default data type) and oVar2 is being explicitly declared as an Object. The following code will produce two Object variables:

   Dim oVar1 As Object
   Dim oVar2 As Object

For more information about dimensioning variables, click the Office Assistant in the Visual Basic for Applications Editor, type "Dim," click Search, and then click to view "Dim Statement."


Additional query words: tshoot declaration declaring dimension Byte
Boolean Integer Long Currency Single Double Decimal Date String
Keywords : kbwordvba kbcode kbprg
Version : 97
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: February 11, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.