Module Module1
Delegate Function Numbers(ByVal A As Double, ByVal B As Double) As Double
Function SubtractNumbers(ByVal A As Double, ByVal B As Double) As Double
SubtractNumbers = A - B
End Function
Function AddNumbers(ByVal A As Double, ByVal B As Double) As Double
AddNumbers = A + B
End Function
Sub Main()
Dim DoNumbers As New Numbers(AddressOf SubtractNumbers)
Console.WriteLine(DoNumbers.Invoke(100, 50))
DoNumbers = AddressOf AddNumbers
Console.WriteLine(DoNumbers.Invoke(100, 50))
End Sub
End Module
|