Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: VB5,VB6
Expertise: beginner
Apr 20, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

IsMissing returns False with non-Variant arguments

Every now and then I forget that the IsMissing function always returns False when the argument is not a Variant value. This happens because IsMissing does nothing more than converting its argument to Variant and testing for a special VarType value. For this reason, the following code is a symptom of a probable bug:

Sub DoSomething(Optional value As Long)
  If IsMissing(value) Then
    ' this code will be NEVER executed !!!
  End If
End Sub
Another little known quirk of the IsMissing function is that it always return False once the parameter has been set to an explicit value from within the procedure, as in:

Sub DoSomething(value1 As String, Optional value2 As Variant)
  If IsMissing(value2) Then
    value2 = value1
  End If
  If IsMissing(value2) Then
    ' this code will be NEVER executed !!!
  End If
End Sub
Francesco Balena
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date