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 (891406)



The information in this article applies to:

  • Microsoft Visual Basic 6 Deluxe Learning Edition
  • Microsoft Visual Basic Enterprise Edition for Windows, Version 6.0
  • Microsoft Visual Basic for Applications 6.0
  • Microsoft Visual Basic Learning Edition for Windows 6.0
  • Microsoft Visual Basic Professional Edition for Windows 6.0

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:For additional information about the support options available from Microsoft, visit the following Microsoft Web site: 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(parameter) 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 ("Not Missing f")
	Else
		MsgBox ("Missing f")
	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.

Modification Type:MajorLast Reviewed:12/15/2005
Keywords:kbprb KB891406 kbAudDeveloper