Defining Delegates
The procedure for defining new delegates is very similar to declaring subroutines and functions, except without the function and subroutine body. The key to defining delegates is to decide whether you need a function or a subroutine and what information you want to pass to the handler procedure.
From the signature of the existing EventHandler delegate, we can derive the EventHandler declaration as stated previously:
Delegate Sub EventHandler( ByVal sender As Object, _ e As System.EventArgs )
Suppose you wanted a delegate that defined a function taking two string arguments and returning a Boolean. Perhaps you would use this to define comparison behavior; you would define the delegate as follows:
Delegate Function Compare(ByVal ...
Get Visual Basic® .NET Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.