|
-
Jan 1st, 2006, 11:39 AM
#1
Thread Starter
Member
Calling procedure by string value (Resolved)
I have a table and in it I have over 100 procedure names, the procedures themselves are part of the applicaiton. Is it possible to get the value from the table and call the procedure accordingly without using any case or if statments. i.e. a string, Mystring will have a value Proc1 and using this value I will call Proc1.
Last edited by stems; Jan 7th, 2006 at 10:55 AM.
-
Jan 1st, 2006, 12:14 PM
#2
Re: Calling procedure by string value
You would need to use reflection.
VB Code:
'Get the type of the current instance.
Dim myType As Type = Me.GetType()
'Get a MethodInfo object by specifying the name of the method.
Dim myMethodInfo As Reflection.MethodInfo = myType.GetMethod("MethodName")
'Call the method on the current instance with no arguments.
myMethodInfo.Invoke(Me, Nothing)
This would be equivalent to:
-
Jan 1st, 2006, 12:36 PM
#3
Thread Starter
Member
Re: Calling procedure by string value
Thanks, I will read a little on reflection and give it a try.
-
Jan 3rd, 2006, 01:37 PM
#4
Fanatic Member
Re: Calling procedure by string value
Since this thread isn't marked as resolved, I will add Delegates. Give a search for Delegates and you will find additional information about them.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|