Microsoft KB Archive/891406

= The IsMissing function may not work correctly when you declare a function with a parameter that is both optional and of the Variant data type in Visual Basic 6.0 =

Article ID: 891406

Article Last Modified on 8/13/2007

-

APPLIES TO


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

-





SYMPTOMS
When you work with Microsoft Visual Basic 6.0, the IsMissing function may not work correctly when you define a function with a parameter that is both optional and of the Variant data type.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and the tools that are used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, visit the following Microsoft Web site:

https://solutionfinder.microsoft.com/

For additional information about the support options available from Microsoft, visit the following Microsoft Web site:

http://support.microsoft.com/default.aspx?scid=fh;[LN;CNTACTMS]

When you define a parameter as a variant in Visual Basic 6.0, you guarantee that there will be a value passed into the function. Therefore, the application will return false whenever the IsMissing method is called. The following code example demonstrates how to define a variable as both optional and a variant in Visual Basic 6.0: Private Function SampleFunction(Optional f As Variant) On Error Resume Next If IsMissing(f) Then MsgBox (&quot;Not Missing f&quot;) Else MsgBox (&quot;Missing f&quot;) End If End Function Note This problem does not occur in versions of Microsoft Visual Basic that were released after Microsoft Visual Basic 6.0.



STATUS
This behavior is by design.

Keywords: kbprb KB891406

-

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

© Microsoft Corporation. All rights reserved.