You can still use CallByName in VB.NET. Any reason why you wouldn't want to
use that? What you would need is to create an instance of the object from
the class name. Use Activator.CreateInstance to create an instance of the
object. Also, you'll need to use the Type.GetType method to get the type of
the object from the class name. Note that you will have to provide the fully
qualified class name - including namespace and assembly name if the class is
in another assembly. Look up the documentation for Type.GetType to get it to
work correctly in your case. If the class is the same one as the executing
assembly, you can do this for your class (say TestClass which is within
namespace TestNameSpace):
Dim ty As Type = Type.GetType("TestNameSpace.TestClass")
Dim obj As Object = Activator.CreateInstance(ty)
CallByName(obj, "TagValue", CallType.Set, "Tag Value is Set")
Dim Tag As String = _
CStr(CallByName(obj, "TagValue", CallType.Get))
Dim Return As Int16 = _
CallByName(obj, "Find", CallType.Method, _
1, "Tag Name", myDataTable)
hope that helps..
Imran.
"Jean-Yves" <je******@gmx.net> wrote in message
news:Oa**************@TK2MSFTNGP11.phx.gbl...
Hi people.
I am trying to replace the old CallByName function of VB6 with those of
.NET
I have a Class with a String Property and a Method with 3 arguments which
returns a DateValue.
How do I use reflexion (with Invoke as I as told) to pass values the
property and call the method on that class.
Basically my class names would be stored as string a config file and, I
would dynamically call them.
My Class has the following member:
Public property TagValue () As String
Public Function Find(ByVal StartPosition As Int32, ByVal TagName As
String, ByVal MySource As DataTable) As Int16
A short example based on that definition would be of great help.
Thanks,
Jean-Yves