473,396 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Is there difference betweein using AddressOf and Delegate?

Is there a difference between AddressOf and Delegate for assiging a
function/Sub to an event?

Add_Handler txt1.Click AddressOf WhatColorFont

or

Private Sub Delegate WhatColorFont()
....

Is there any difference between these or is it just a one or the other thing?

Thanks,
Rich
Jan 7 '08 #1
2 1460
On Jan 7, 2:29 pm, Rich <R...@discussions.microsoft.comwrote:
Is there a difference between AddressOf and Delegate for assiging a
function/Sub to an event?

Add_Handler txt1.Click AddressOf WhatColorFont

or

Private Sub Delegate WhatColorFont()
...

Is there any difference between these or is it just a one or the other thing?

Thanks,
Rich
You use AddressOf to implicitly create the delegate instead of doing
it by hand. I would recommend just using AddressOf for simplicities
sake, though it doesn't really matter.

Thanks,

Seth Rowe [MVP]
Jan 7 '08 #2
Thank you. That really helps to demystify delegates. I think I have it
straight now.

"rowe_newsgroups" wrote:
On Jan 7, 2:29 pm, Rich <R...@discussions.microsoft.comwrote:
Is there a difference between AddressOf and Delegate for assiging a
function/Sub to an event?

Add_Handler txt1.Click AddressOf WhatColorFont

or

Private Sub Delegate WhatColorFont()
...

Is there any difference between these or is it just a one or the other thing?

Thanks,
Rich

You use AddressOf to implicitly create the delegate instead of doing
it by hand. I would recommend just using AddressOf for simplicities
sake, though it doesn't really matter.

Thanks,

Seth Rowe [MVP]
Jan 7 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Billy Jacobs | last post by:
Can someone tell me what the problem with this code is. Specifically the line in all caps near the bottom. I am getting an error on this line saying: "Property Access must assingn to the property...
6
by: ECVerify.com | last post by:
I am trying to figure out how to do this in C Sharp In VB this works perfect MenuItem2.MenuItems.Add("123", AddressOf Me.MenuItem1_Click) The problem is there is no address of in C#, I tried...
6
by: Simon Verona | last post by:
I would normally use code such as : Dim Customer as new Customer Dim t as new threading.thread(AddressOf Customer.DisplayCustomer) Customer.CustomerId=MyCustomerId t.start Which would create...
2
by: john | last post by:
Hello, I am trying to convert from vb6 to vb.net and I have an issue with the addressOf function. Below is the code any help would be greatly appreciated. Thanks in advance. code erroring...
4
by: ItsMe | last post by:
Hi Guyz, I'm unable to understand this (AddressOf) error??? In VB6 I have two functions: ---------------------------- Public Function ImageFirstImageCallback(ByVal hWnd As Integer, ByVal...
4
by: Anthony Coelho | last post by:
Hello Guru's! I am trying to pass a function pointer as a parameter to a method and can't seem to get it working. Basically I want to do the exact same thing that the System.Threading.Thread...
2
by: jcomber | last post by:
Hi, I'd be grateful for some help... I'm trying to create a late bound object using: Activator.CreateInstance(Type, ConstructorParameters()) The constructor of the object takes a delegate...
4
by: kaczmar2 | last post by:
I have a custom web control that is called from an aspx page. The custom control dynamically renders out buttons via a public method (AddButton). One of the attributes of the method is a...
1
by: JOHNDOE | last post by:
All right, I've been trying to wrap my head around this by reviewing what is out on the web but still seem to be struggling with this.... Here is the calling code with the AddressOf Error: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.