PRB: "Object not a Collection" Trying to Read Array ElementLast reviewed: September 29, 1997Article ID: Q129871 |
The information in this article applies to:
SYMPTOMSIf a public member of a class of type variant is assigned an array, you get the following error message when trying to read an element of the array by directly indexing the variant member:
Object not a Collection.This happens only if the instance of the class object is late bound; that is, the instance is dimensioned "As Object."
RESOLUTION
STATUSThis behavior is by design.
MORE INFORMATION
Steps to Reproduce Behavior
Example WorkaroundTo work around the behavior, declare the object with a specific object type instead of Object. In Step 3 above, replace:
Dim x As Objectwith:
Dim x As New Class1Then change the Set statement into a comment. After making these changes, run the program again. You should see a value of 5 in the Debug Window. Keywords : IAPVBA VB4ALL VB4WIN vbwin GnrlVb kbprg Technology : kbvba Version : WINDOWS:4.0 Platform : WINDOWS Issue type : kbprb |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |