Thread: Delegates help
View Single Post
Old 07-25-2008   #3 (permalink)
Miro


 
 

Re: Delegates help

I might still be missing something but I see how the delegate points to the
function/method :

But I still seem to be missing why I wouldnt call the sub "DisplayMessage"
directly? Why delegate it?

Thanx,

Miro

=====
Public Class Form1

Delegate Sub MyFirstDelegation(ByVal blaTxt As String)


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim deleg As MyFirstDelegation
deleg = New MyFirstDelegation(AddressOf DisplayMessage)

deleg.Invoke("Why not just call display message directly")

Debug.WriteLine("when did this line get hit?")
End Sub

Sub DisplayMessage(ByVal msgText As String)
MessageBox.Show(msgText, "delegation")
End Sub

End Class
=====

My System SpecsSystem Spec