How do I tell if an object has a method? I'm wanting to write a function in a regular module, something like
public function NextSpan(Cnt as Object) as string
if( HasMethod(Cnt, "Span") then
NextSpan = Cnt.Span
else
NextSpan = DefaultSpan()
end function
I suppose I could just trap the error
public function NextSpan(Cnt as Object) as string
on error GoTo DefaultSpan
NextSpan = Cnt.Span
exit function
DefaultSpan:
NextSpan = DefaultSpan()
End Sub
But that doesn't distinguish between the cases where Cnt doesn't have the method, and cases where Cnt has the method, but it's buggy and throwing an error.
Bookmarks