Rico,
I use the following where MethodName is the name of the method to invoke.
<code (VB.NET) >
Dim aType As Type = SomeClass.GetType
Dim Args() as Object = {Arg1, Arg2,...}
Dim aFunctionReturn As Object
aFunctionReturn = aType.InvokeMember(MethodName _
, Reflection.BindingFlags.InvokeMethod
_
, Nothing _
, aFeatureClass.Instance _
, Args)
Return aFunctionReturn
</code>
In my applications everything is a "plugin", so the "host" application looks
at the database to determine the users available options. From this list I
load the appropriate classes at runtime and invoke a standard set of methods
on the class which are defined by an interface.
-Sam Matzen
-Sam Matzen
"Rico Rivera" <qR********@spamhole.com> wrote in message
news:40****************@news.verizon.net...
I want to call a method dynamically based on a string
For example
When s = "A" Then method A would get called. I don't wan't to use a
bunch of "If" statements.
Something like:
someMethod = AddressOf s 's = A
someMethod(SomeSortOfString)
Sub A(ByRef SomeString As String)
...
End Sub
Sub B(ByRef SomeString As String)
...
End Sub
Is this possible?