The following "aMacro" returns the error "Ambiguous name Detected" I understand why. Anybody know a way to override the first definition and and only use the definition inside of the function so that aFunction will return x - y ?
Besides changing the name.
Function aFunction(x As Integer, y As Integer) As Integer
aFunction = x + y
End Function
Sub aMacro()
Function aFunction(x As Integer, y As Integer) As Integer
aFunction = x - y
End Function
MsgBox aFunction(4, 3)
End Function
This can simulate "override function" with 4 class modules: Functions, IFunction, FunctionAdd, FunctionSubtract.
class module Functions:
interface IFunctions:
class module FunctionAdd:
Class module FunctionSubtract:
You can test this with this:
Of course this is tedious for one function. I could be useful is you have a lot of functions to override in many classes.
A function can be
Private
orPublic
, but the scope is always the whole module.Try adding in the Optional value in the function. If the optional value isnt included in the call then it wont be references in the function.