View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Passing a Function name as a procedure argument

Thanks for the correction.



Bob Phillips wrote:

Nah, 2000 has it.

--

HTH

RP
(remove nothere from the email address if mailing direct)

"Dave Peterson" wrote in message
...
And I think you need xl2002 or higher to use CallByName.

"Mark H. Shin" wrote:

Sorry for the double post but the following example is bit more to what

you
need:

Module Module1:
Sub test()
Dim M As New MathLibrary

result1 = CallByName(M, "FuncA", VbMethod, 2345, 4321)
result2 = CallByName(M, "FuncB", VbMethod, 2)
End Sub

Class MathLibrary:
Public Function FuncA(a As Double, b As Double) As Double
FuncA = a / b
End Function
Public Function FuncB(a As Double) As Double
FuncB = a ^ 2
End Function

" wrote in message
oups.com...
1. I have a Standard Module Function:
Public Function GetARoot(ByVal FirstGuess As Double, ByVal
FunctionName As _
String) As Double
that calculates the root of an equation.

I have several equations programmed as Functions in the Standard
Module. I wish to pass the name of one of these Functions as an
argument to "FunctionName" and call the Function with this name from
inside GetARoot.

Can this be done?


--

Dave Peterson


--

Dave Peterson