Using VB.Net
I am using the CallByName() function to call certain subroutines based on a selection made by the user. The options for the subroutines come from a dropdown menu which gets it data from a table in a database. The CallByName function requires the starting class and the subroutine name as well as the method type ex: CallByName(class,subroutine,type.method). In my table I have a column for the class and a column for the subroutine. So these get read by my program as strings. I'm trying to use these variables in the function and while the subroutine string works fine, I can't seem to convert the class string into a proper class object that can be used by the CallByName function.
My code looks like:
Dim base_class as string = myReader(0)
Dim subroutine as string = myReader(1)
base_class = CType(base_class, class)
'* what I need, but doesn't work ^^^
CallByName(base_class, subroutine, CallType.Method)
How can I convert the class variable read in from the DB into something that I can use in the function?
Thanks.
Edit: The code that I ended up using that worked based on Jimi's response:
Dim t As Type = Type.GetType(base_class)
Dim obj = Activator.CreateInstance(t)
CallByName(obj, subroutine , CallType.Method)