delegate - part 1

Posted on 2006-04-09
Last Modified: 2010-04-23
Could someone explain what the heck it delegate and provide a sample?  I'm confused.
Question by:VBdotnet2005
    LVL 48

    Expert Comment

    LVL 62

    Expert Comment

    by:Fernando Soto
    hI VBdotnet2005;

    Here is a site on delegates:

    A Beginner's Guide to Delegates:
    Has downloadable VB .Net Project showing its use.

    LVL 14

    Accepted Solution

    A delegate is merely a function pointer.

    With a delegate you describe what a function you can call from 'another place' looks like


    public delegate sub MyDelegate(var as String)

    Meaning: the function you are passing will look like:
    sub MyDelegate(var as String)

    You can create vars of that type and call it like a function:
    dim myDel as MyDelegate

    NOTE: myDel needs to be instantiated first:

    e.g. from your class that actually contains the real method:

    dim myDelegateClass as new myDelegateClass
    myDelegateClass.SetMyDelegate(Addressof MySubThatLooksTheSameLikeMyDelegate)

    And in this class you will have a method like:

    private sub MySubThatLooksTheSameLikeMyDelegate (werwer as String)


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now