XL5: Data Type Example Does Not Work with Dynamic Array

Last reviewed: September 12, 1996
Article ID: Q119131
The information in this article applies to:
  • Microsoft Excel for Windows, versions 5.0, 5.0c

SYMPTOMS

When you run the example code on page 118 of the "Visual Basic User's Guide," included with Microsoft Excel version 5.0, you receive the following error message:

   Run-time error '9':
   Subscript out of range

The following code assumes that you are referring to the fixed-size array example:

   Dim MySystem As SystemInfo
   MySystem.DiskDrives(1)="1.44 MB"

However, if you use this code with a dynamic array, you receive the error message above.

WORKAROUND

To work around this problem, add the Redim statement to the code in the example, as shown in the example below:

   Dim MySystem As SystemInfo
   Redim MySystem.DiskDrives(5) As String
   MySystem.DiskDrives(1)="1.44 MB"

REFERENCES

"Visual Basic User's Guide," version 5.0, page 118


KBCategory: kbprg
KBSubcategory: kbcode kbdocerr

Additional reference words: 5.00



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: September 12, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.