atesh Posted August 4, 2003 Posted August 4, 2003 Is there a way to make an array of functions? Essentially: Private Sub GamePlay() Call Question(x)() End Sub Private Sub Question1() .... End Sub Private Sub Question2() .... End Sub etc. Quote To err is human, to really foul things up requires a computer.
*Experts* Volte Posted August 4, 2003 *Experts* Posted August 4, 2003 No need. Put all your Question subs inside a class, create an instance of it, and then you can use this function: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 SubTo call each function by its name. So some code like this would work:Dim q As New Questions() 'Questions being the class containing all the Question subs. MethodByName(q, "Question" & myNumber, New String()) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.