Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Spiff

Checking for objects set to nothing in VB

This topic is 6777 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is a VB only question.

If I've got a function that has an Optional parameter (a class), how do I check if it's passed or not? The IsMissing() function doesn't seem to work on classes.

Share this post


Link to post
Share on other sites
Advertisement
Use a structure like this:

code:

Private Sub Something(Optional clsParam As clsTest)

If clsParam Is Nothing Then
MsgBox "Missing parameter"
Else
MsgBox "Parameter passed"
End If

End Sub


This assumes that the class you're passing has been initialized.

IsMissing only works for optional variants, which is rarely used now that optional parameters can be any data type. This is probably a carryover from VB4 when optional parameters had to be variants.

------------------
Breakaway Games

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!