I'm trying to create a program that inputs a command from the user e.g. "add 2 4" and then calls a method based on that command. So I type in the command string "add 2 4", then a parser reads the first word "add" and outputs it as the name of the routine, sends that routine name to another sub with the parameters, and then calls the relevant sub.
Essentially I'm trying to avoid this:
Select Case RoutineName.ToUpper
Case "ADD"
Add(Param1, Param2)
Case "SUBTRACT"
Subtract(Param1, Param2)
Case "MULTIPLY"
Multiply(Param1, Param2)
...
Because I want to be able to easily add references to a new sub without having to continually update a Selection statement.
I saw someone else having the same problem: Create a method call in .NET based on a string value but I couldn't make sense of any of the answers to his question, or they weren't in VB. One person suggested using a dictionary of delegates, with a string as a key. This sounds like a great idea, but delegates confuse me a great deal: would anyone be able to show me how this solution might be implemented?