XL5: Data Type Example Does Not Work with Dynamic Array

ID: Q119131

5.00 5.00c WINDOWS kbprg kbcode kbdocerr

The information in this article applies to:

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

Keywords          : kbcode kbdocerr 
Version           : 5.00 5.00c
Platform          : WINDOWS

Last Reviewed: September 15, 1996