Returns a non-zero number if the specified value has a method by the specified name.

HasMethod := HasMethod(Value, Name)



Type: Any

Any value, of any type except ComObject.


Type: String

The method name to check for.

Return Value

Type: Integer (boolean)

This function returns true if the value has a method by this name, otherwise false.


This function can be used to estimate whether a value supports a specific action. For example, values without a Call method cannot be called or passed to SetTimer, while values without either an __Enum method or a Call method cannot be passed to For. However, the existence of a method does not guarantee that it can be called, since there are requirements that must be met, such as parameter count.

A return value of false does not necessarily indicate that the method cannot be called, as the value may have a __Call meta-function. However, __Call is not triggered in certain contexts, such as when __Enum is being called by For. If __Call is present, there is no way to detect which methods it may support.

This function supports primitive values.


Objects, HasBase, HasProp



MsgBox HasMethod(0, "HasMethod") ; 1
MsgBox HasMethod(0, "DefineMethod") ; 0