array of functions?

atesh

Freshman
Joined
Aug 2, 2003
Messages
41
Location
Washington State, USA
Is there a way to make an array of functions? Essentially:

Visual Basic:
Private Sub GamePlay()
Call Question(x)()
End Sub

Private Sub Question1()
....
End Sub

Private Sub Question2()
....
End Sub

etc.
 
No need.

Put all your Question subs inside a class, create an instance of it, and then you can use this function:
Visual Basic:
Private Sub MethodByName(ByVal obj As Object, ByVal method As String, ByVal args As String())
        Dim t As Type
        t = obj.GetType
        t.InvokeMember(method, Reflection.BindingFlags.InvokeMethod, t.DefaultBinder, obj, args)
End Sub
To call each function by its name. So some code like this would work:
Visual Basic:
Dim q As New Questions() 'Questions being the class containing all the Question subs.

MethodByName(q, "Question" & myNumber, New String())
 
Back
Top