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.
Checking for objects set to nothing in VB
This is a VB only question.
============================Daniel Netz, Sentinel Design"I'm not stupid, I'm from Sweden" - Unknown
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 IfEnd 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
Former Microsoft XNA and Xbox MVP | Check out my blog for random ramblings on game development
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement