Reputation: 7830
How do I check for an empty object in VB? Specifically, a function may sometimes return the following:
Return {}
How I check whether {}
is returned as compared to an object with properties and data? Thanks.
Upvotes: 0
Views: 4155
Reputation: 531
For me Dim cellValue = DataRow.Item("SomeName")
sets cellValue
to {}
So to check it:
If (VarType(cellValue) = vbNull) Then
...
End If
Upvotes: 0
Reputation: 12748
That just returns an empty array. The array will depend on the return type of the function or it will be Object(). Just check if .Length is equal to 0.
I assume you have Option Strict Off, you should turn it on :)
Upvotes: 4