XL5: Data Type Example Does Not Work with Dynamic Array


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

Additional query words:

Keywords : kbcode kbdocerr
Version : WINDOWS:5.0,5.0c
Platform : WINDOWS
Issue type :
Technology :


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