Microsoft KB Archive/193261

= BUG: Error 458 Using For Each with Variant Array of UDTs =

Article ID: 193261

Article Last Modified on 5/13/2003

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q193261



SYMPTOMS
When you use a For Each to loop over a Variant containing an array of User Defined Types (UDTs), the following error may occur:

Run-time error '458': Variable uses an Automation type not supported in Visual Basic.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.



Steps to Reproduce Behavior
 Create a new ActiveX EXE project in Visual Basic. Class1 is created by default.  Paste the following code into Class1: Type MyType x As Integer y(5) As Integer End Type

 Add a standard module to the project by selecting "Add Module" from the "Project" menu.  Paste the following code into Module1: Sub main Dim x(5) As MyType Dim y as Variant y = x        For Each g In y         Next g      End Sub

 Open the Immediate Window by selecting it from the View menu. Type "main" (without quotes) into the Immediate Window and press the ENTER key to run the main subroutine. Note that the above error occurs on the For Each line.

NOTE: If you change the line "For Each g In y" to "For Each g In x" so that the "For Each" statement will loop through the array X, the correct error description "For Each may not be used on an array of user-defined types or fixed-length strings" will occur instead.</li></ol>

Additional query words: kbdss kbDSupport kbVBp kbVBp600bug kbCompiler

Keywords: kbbug KB193261

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.