473,472 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

AddressOf issue, can somebody explain this?

first line fails with "Reference to a non-shared member requires an object
reference."
yet second line works... any reasons?

ctxMenu.MenuItems.Add("Add new pattern...", AddressOf
mtTemplateNode.cmdPatternAdd_Click)
ctxMenu.MenuItems.Add("Add new pattern...", New
System.EventHandler(AddressOf mtTemplateNode.cmdPatternAdd_Click))
--
Eric Newton
C#/ASP Application Developer
http://ensoft-software.com/
er**@cc.ensoft-software.com [remove the first "CC."]
Nov 20 '05 #1
2 1179
the new in the second line creates an mtTemplateNode object
one does not exist in the first line

Hope this helps..

"Eric Newton" <er**@cc.ensoft-software.com> wrote in message
news:eX**************@TK2MSFTNGP11.phx.gbl...
first line fails with "Reference to a non-shared member requires an object
reference."
yet second line works... any reasons?

ctxMenu.MenuItems.Add("Add new pattern...", AddressOf
mtTemplateNode.cmdPatternAdd_Click)
ctxMenu.MenuItems.Add("Add new pattern...", New
System.EventHandler(AddressOf mtTemplateNode.cmdPatternAdd_Click))
--
Eric Newton
C#/ASP Application Developer
http://ensoft-software.com/
er**@cc.ensoft-software.com [remove the first "CC."]

Nov 20 '05 #2
Eric,
What type of construct is mtTemplateNode?

Is it an object, a class, a form, a structure, a variable, something else?

If mtTemplateNode is the name of a class, you cannot (should not) add an
event at the class level to an instance method. You will get a null
reference exception when the event itself was raised.

Try
Dim node As New mtTemplateNode
ctxMenu.MenuItems.Add("Add new pattern...", AddressOf
node.cmdPatternAdd_Click)
ctxMenu.MenuItems.Add("Add new pattern...", New
System.EventHandler(AddressOf node.cmdPatternAdd_Click))
Notice that I am using an instance of the mtTemplateNode class for the event
handler.

Alternatively put Shared in front of the cmdPatternAdd_Click method.

Hope this helps
Jay

"Eric Newton" <er**@cc.ensoft-software.com> wrote in message
news:eX**************@TK2MSFTNGP11.phx.gbl... first line fails with "Reference to a non-shared member requires an object
reference."
yet second line works... any reasons?

ctxMenu.MenuItems.Add("Add new pattern...", AddressOf
mtTemplateNode.cmdPatternAdd_Click)
ctxMenu.MenuItems.Add("Add new pattern...", New
System.EventHandler(AddressOf mtTemplateNode.cmdPatternAdd_Click))
--
Eric Newton
C#/ASP Application Developer
http://ensoft-software.com/
er**@cc.ensoft-software.com [remove the first "CC."]

Nov 20 '05 #3

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

Similar topics

4
by: John Dean | last post by:
Hi I have been reading quite a lot of Python source code recently and I have come across a particular construct which I don't understand. I would be grateful if somebody could explain the reason...
3
by: Paul Mateer | last post by:
Hi, I have been running some queries against a table in a my database and have noted an odd (at least it seems odd to me) performance issue. The table has approximately 5 million rows and...
12
by: Bill | last post by:
When I compile the following code fragment, the compiler errors saying the variable connection is not initialized. As I understand C#, I thought it would be initialized. Please help me and explain...
6
by: Robert Warnestam | last post by:
I've two class libraries, where one is referencing the other. The first library looks like this; (assembly name and root name space is set to Codab.Parser) namespace Codab.Parser { public class...
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...
2
by: Brett | last post by:
I'm creating a second thread from my main form like this: Public t As System.Threading.Thread = New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf _...
3
by: Dav | last post by:
Hi, I moved over client side javascript code from an asp.net 1.1 project to an asp.net 2.0 project. When I view the web page, I get all these "is null or is not object" javascript errors. Is...
6
by: Carlo3030 | last post by:
Been reading Dino Esposito's Article "A DetailsView Control for ASP.NET 1.x" found in the msdn Library. His example was created using VB.NET. I am trying to convert the example (DetailsView...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
1
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.