Let user call a function/sub from a command/shell window  
Author Message
gareth andrew lewis





PostPosted: Visual Basic General, Let user call a function/sub from a command/shell window Top

Is there a simple way to allow the user of a program to type in a function with or without parameters and then the program would execute this command I guess we could have a huge switch (or select) statement that just reads the user input and executes the respective command, but I was wondering if visual basic has a component that makes this easier, because there are hundreds of functions that the user can call and other functions will be added in the future, so it seems inefficient to hard code all of the function calls like this. any help is appreciated.

eg.
user types in the window... create_wall("front") while the program is running and the sub below is executed.

Public Sub create_wall(ByVal name as string)
walls.add(name)
...
End Sub


thanks,
gareth


Visual Basic1  
 
 
DMan1





PostPosted: Visual Basic General, Let user call a function/sub from a command/shell window Top

Public Function CallByName(ByVal ObjectRef As Object, ByVal ProcName As String, ByVal UseCallType As Microsoft.VisualBasic.CallType, ByVal ParamArray Args() As Object) As Object

Member of: Microsoft.VisualBasic.Interaction

Summary:

Executes a method on an object, or sets or returns a property on an object.

Parameters:

ProcName: Required. String. A string expression containing the name of the property or method on the object.

UseCallType: Required. An enumeration member of type CallType Enumeration representing the type of procedure being called. The value of CallType can be Method, Get, or Set.

ObjectRef: Required. Object. A pointer to the object exposing the property or method.

Args: Optional. ParamArray. A parameter array containing the arguments to be passed to the property or method being called.

Return Values:

Executes a method on an object, or sets or returns a property on an object.