Microsoft KB Archive/105549

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 16:04, 18 July 2020 by 3155ffGd (talk | contribs) (importing KB archive)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

WordBasic Error with Array Dimensioned for 0 (Zero) Elements

Q105549



The information in this article applies to:


  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows, version 7.0





SYMPTOMS

If you dimension an array with no elements using a statement such as Dim Array$(-1), a WordBasic error occurs when you run the macro. This problem did not occur in Word version 2.x for Windows.

As a result, if your macro dimensions an array based on a count, the macro fails if the count is 0 (zero). For example, the following macro will fail if the last FileFind statement finds no matches:

   Dim Array$(CountFoundFiles() - 1) 

This also means you cannot display an empty list box in a dialog box; it must always contain one empty element.



STATUS

We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



WORKAROUND

You must rewrite your macro so it contains no arrays with 0 elements. For example, use the following statement to dimension an array that contains an extra element:

   (Dim a$(countfoundfiles())) 

When you write a new macro, check to be sure your array will not contain 0 elements.



MORE INFORMATION

An array in WordBasic has as many elements as its last index plus 1, which means that an array dimmed as 0 actually has one element. Therefore, Dim Array$(-1) dimensions an array with no elements.

Kbcategory: kbusage kbmacro

Additional query words: 6.0 winword word6 7.0 word95 word7

Keywords :
Issue type :
Technology :


Last Reviewed: November 4, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.