Mega Code Archive

 
Categories / VB.Net Tutorial / Class Module
 

Define a delegate to be a pointer to a subroutine that has a string parameter

public class Test    public Shared Sub Main         Dim m_DisplayStringRoutine As StringDisplayerType         m_DisplayStringRoutine = AddressOf ShowStringInMessageBox ' ShowStringInOutputWindow         m_DisplayStringRoutine("Hello world")    End Sub     Private Delegate Sub StringDisplayerType(ByVal str As String)     Private Shared Sub ShowStringInOutputWindow(ByVal str As String)         Console.WriteLine(str)     End Sub     Private Shared Sub ShowStringInMessageBox(ByVal str As String)         Console.WriteLine("+++"+str)              End Sub End class +++Hello world