BUG: Optional Parameter with Default Value of Null Causes Error 458 at Compile (265884)



The information in this article applies to:

  • Microsoft Visual Basic Professional Edition for Windows 5.0
  • Microsoft Visual Basic Professional Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 5.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0

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.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Start a new ActiveX DLL project in Visual Basic 6.0. Class1 is added by default.
  2. Paste the following code into the code window of Class1:
    Option Explicit
    
    Public Sub Method1(Optional ByVal x As Variant = Null)
    '
    End Sub
    					
  3. On the File menu, select Save Project.
  4. On the File menu, select Make Project1.dll, and note that you receive the previous error message immediately.
  5. Change Null to vbNull in the preceding code, repeat steps 3 and 4, and note that the project compiles without error.

Modification Type:MajorLast Reviewed:1/12/2004
Keywords:kbBug kbpending KB265884