here's the idea:
(Note: watch for typos and syntax - I'm directly typing this in this message
so you'll have to double check syntax, etc etc)
first - trim the string to get the class name, method name and method
parameter(s) seperated out.
Dim str As String = "cls.CallFuncti on(strParameter )"
Dim ClassName As String = str.SubString(1 , str.IndexOf("." )-1)
Dim MethodName As String = _
str.SubString(s tr.IndexOf(".") +1, str.IndexOf("(" ) - str.IndexOf("." ))
Dim Parameter As String = _
str.SubString(s tr.IndexOf("(") +1, str.Index(")") - str.Index("("))
(you'll have to do a little more work if you have more than one parameter)
Then use Type.GetType( ) method to get the type object for your class (read
up the documentation on Type.GetType( ) to make sure you get it right -
there are several rules on how to pass in the class name; for instance, you
need to pass in your application name, namespace name, etc etc)
Something like:
Dim myType As Type = Type.GetType(my AppName & myNameSpace & ClassName)
Then use the InvokeMember function of the type class to execute the method.
Something like:
Dim args( ) As Object = {strParameter}
myType.InvokeMe mber("CallFunct ion", BindingFlags.Pu blic Or _
BindingFlags.In vokeMethod, Nothing, Nothing, args)
(make sure you get the BindingFlags right otherwise it'll blowup here.
lookup the various values for BindingFlags and use the ones that match the
criteria for your method)
Well - thats just about the idea on how to do this.
hope that helps..
Imran
..
"Amanda" <de*****@hotmai l.com> wrote in message
news:55******** *************** ***@posting.goo gle.com...
Let me see if I can explain this correctly.
In VB.NET, I want to call classes based on a recordset I get back from
a SQL Server database.
Basically, I have a value sending in a table called
cls.CallFunctio n(strParameter) .
In VB.NET cls.CallFunctio n is a class and a function in my code.
How do I convert my recordset value (cls.CallFuncti on (strParameter))
into a string value that will actually call the function.
Gosh, I hope that makes sense, and I didn't sound like a complete
idiot
Please respond back to this post :)
Thanks!