Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"hasmethod" function?

Status
Not open for further replies.

venkman

Programmer
Oct 9, 2001
467
US
Is there a way to see if an object has a method? like:
if hasmethod(myobj, mymethod) then
myobj.mymethod
else
'do something else
end if

-Venkman
 
Crude, but it works:

on error resume next
myobj.mymethod
if err=438 then
err.clear
..do alternate stuff here
elseif err<>0 then
error err
end if
Rob
[flowerface]
 
Thanks Rob. I was hoping there was a more elegant solution (ie. less lines of code to do it) . Is there any way to write this as a function which returns a boolean.
-Venkman
 
I can't think of a way to do it as a function. Once you've debugged your code, you code get rid of two lines (the elseif bit), which makes this hardly any longer than a function-based approach (though, admittedly, not as clean).
Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top