Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From your code, function g takes a string parameter and returns a string. I suggest you create a class module called IStringFunction to act as the definition of an interface that all functions will support, thus:</p> <p><strong>Class Module: IStringFunction</strong></p> <pre><code>Public Function Evaluate(ByVal s As String) As String End Function </code></pre> <p>Then, create a couple of example functions implementing this interface:</p> <p><strong>Class Module: HelloStringFunction</strong></p> <pre><code>Implements IStringFunction Public Function IStringFunction_Evaluate(ByVal s As String) As String IStringFunction_Evaluate = "hello " &amp; s End Function </code></pre> <p><strong>Class Module: GoodbyeStringFunction</strong></p> <pre><code>Implements IStringFunction Public Function IStringFunction_Evaluate(ByVal s As String) As String IStringFunction_Evaluate = "goodbye " &amp; s End Function </code></pre> <p>...and finally, some test code to exercise the functions:</p> <p><strong>(Standard) Module: Test</strong></p> <pre><code>Sub Test() Dim oHello As New HelloStringFunction Dim oGoodbye As New GoodbyeStringFunction MsgBox Evaluate(oHello, "gary") MsgBox Evaluate(oGoodbye, "gary") End Sub Private Function Evaluate(ByVal f As IStringFunction, ByVal arg As String) As String Evaluate = f.Evaluate(arg) End Function </code></pre> <p>Note that the class implementing the interface must have methods named <code>&lt;Interface&gt;_&lt;Method&gt;</code> as in the example above, not just <code>&lt;Method&gt;</code> as you'd expect.</p> <p>Download the <a href="https://dl.dropbox.com/u/6194904/2012/demo%20functions%20as%20arguments%20of%20functions.xlsm" rel="nofollow noreferrer">simple demo</a> or <a href="https://dl.dropbox.com/u/6194904/2012/demo%20functions%20as%20arguments%20of%20functions%20%28advance%29.xlsm" rel="nofollow noreferrer">intermediate demo</a> here</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload