Microsoft KB Archive/265884

= BUG: Optional Parameter with Default Value of Null Causes Error 458 at Compile =

Article ID: 265884

Article Last Modified on 1/12/2004

-

APPLIES TO


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

-



This article was previously published under Q265884



SYMPTOMS
If you declare an optional parameter of type Variant with the default value set to Null or to Empty in your ActiveX Component Project (such as ActiveX DLL, ActiveX control (OCX), or ActiveX EXE), you receive the following error message (458) when you compile the project:

Variable uses an Automation Type not supported in Visual Basic

Visual Basic does not give you any details on which line of code causes the error.



RESOLUTION
The workaround is to replace Null with the predefined constant vbNull or to replace Empty with the constant vbEmpty.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 Start a new ActiveX DLL project in Visual Basic 6.0. Class1 is added by default.  Paste the following code into the code window of Class1: Option Explicit

Public Sub Method1(Optional ByVal x As Variant = Null) ' End Sub  On the File menu, select Save Project. On the File menu, select Make Project1.dll, and note that you receive the previous error message immediately. Change Null to vbNull in the preceding code, repeat steps 3 and 4, and note that the project compiles without error.</ol>

Additional query words: Error 458 compile-time

Keywords: kbbug kbpending KB265884

-

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

© Microsoft Corporation. All rights reserved.