?
Solved

delegate - part 1

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

Expert Comment

by:Mikal613
ID: 16412595
0
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 16412696
hI VBdotnet2005;

Here is a site on delegates:

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

    http://www.codeproject.com/vb/net/Delegate.asp#xx1428967xx

Fernando
0
 
LVL 14

Accepted Solution

by:
PockyMaster earned 1000 total points
ID: 16414616
A delegate is merely a function pointer.

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

e.g.

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

myDel("werwer")
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)

....
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Loops Section Overview
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

839 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