Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB6 check if variable is an object

In Visual Basic 6, is there anyway to tell if a variable passed into a function is an object? I want to be able to test if the variable is null, nothing or empty but only objects can be tested using "Is Nothing". Any ideas?

like image 884
Mike Avatar asked Dec 22 '22 06:12

Mike


2 Answers

How is the function defined?

If it's ... As Object then it's either a valid object or Null.

If it's ... As Variant (or no type) then anything can be passed and you can check using IsEmpty(), IsNull() (Note, NOT a null object, but a null value) or IsObject() depending on what exactly you want to check for before the ... Is Nothing check.

If the parameter is Optional then you can use IsMissing() but it must be a variant type with no default value.

Also, check out this article on the various uses of Null in VB.

like image 172
Deanna Avatar answered Dec 30 '22 08:12

Deanna


IsObject(variable)

Not difficult to find

like image 42
Andrew Avatar answered Dec 30 '22 10:12

Andrew