I need help with the syntax for passing values through delegates.
I have a delegate:
Delegate Sub MethodCaller()
I have a method:
Sub AnotherMethod()
MsgBox(CurrentMethodName)
End Sub
I call it:
Dim callMethod As MethodCaller
callMethod = AddressOf AnotherMethod
callMethod.Invoke
All ok. Now I have a parameter I want to pass to the method
Delegate Sub MethodCaller(s As String)
Sub AnotherMethod(s As String)
MsgBox(s)
End Sub
Dim callMethod As MethodCaller
callMethod = AddressOf AnotherMethod “some string” <---------is this correct syntax?
callMethod.Invoke
I get an error.
Also can I have a delegate with different number of parameters like a method.
Delegate Sub MethodCaller()
Delegate Sub MethodCaller(s As String)
Delegate Sub MethodCaller(s As String, i As Integer)
Would appreciate some help.