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.
🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Checking for objects set to nothing in VB
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement