.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Delegates in vb.net

Posted By:satyapriyanayak       Posted Date: March 11, 2013    Points: 40    Category: Visual Studio    URL: http://www.dotnetspark.com  

Delegates in vb.net
 

Delegates: - It is a procedure pointer, which stores the memory address of another procedure. It can be applied with

1.Sub procedure

2.Function procedure

But not property procedure.

 

Program

 

Ex1

 

Public Class Form1

    Delegate Sub abhisek(ByVal x As Integer, ByVal y As Integer)

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim a As abhisek

        a = AddressOf rajiv

        a.Invoke(10, 20)

    End Sub

    Public Sub rajiv(ByVal x As Integer, ByVal y As Integer)

        Dim z As Integer

        z = x + y

        MsgBox(z)

    End Sub

End Class

 

Ex2

 

Public Class Form2

    Delegate Sub raj(ByVal x As String)

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim x As raj

        x = AddressOf rajiv

        x.Invoke("Adarsh kumar")

    End Sub

    Private Sub rajiv(ByVal s As String)

        MsgBox("Hello:" & s)

    End Sub

End Class




     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend