PRB: "Object not a Collection" Trying to Read Array Element (129871)
The information in this article applies to:
- Microsoft Visual Basic Standard Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 32-bit, for Windows 4.0
This article was previously published under Q129871 SYMPTOMS
If 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- Dimension the object instance as being of the exact type of the class,
so that it is Early Bound.
-or-
- Index the variant member with another level of parenthesis. For example,
in the "Steps to Reproduce Behavior" section of this article, use:
Debug.Print x.arr()(0)
Debug.Print x.arr(0)
This explicitly specifies that the variant holds an array.
STATUS
This behavior is by design.
Modification Type: | Major | Last Reviewed: | 12/9/2003 |
---|
Keywords: | kbprb kbprogramming KB129871 |
---|
|