473,385 Members | 1,564 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,385 software developers and data experts.

Accessor declarations for events in VB.Net

Hi all,

I'm attempting to port some C# code over to VB.Net. It was going well until
I hit the following code:

public virtual event PInputEventHandler KeyDown {
add { handlers.AddHandler(keyDownEventKey, value); }
remove { handlers.RemoveHandler(keyDownEventKey, value); }
}

It appears that one can declare Add and Remove accessors within an event
declaration in C#. Is there any way to do this in VB.Net?

Thanks.
Nov 21 '05 #1
2 2663
"Luhar" <Lu***@discussions.microsoft.com> schrieb:
I'm attempting to port some C# code over to VB.Net. It was going well
until
I hit the following code:

public virtual event PInputEventHandler KeyDown {
add { handlers.AddHandler(keyDownEventKey, value); }
remove { handlers.RemoveHandler(keyDownEventKey, value); }
}

It appears that one can declare Add and Remove accessors within an event
declaration in C#. Is there any way to do this in VB.Net?


In currently released final versions of VB.NET, there is no way to do that.
VB 2005 will include a similar way to archieve what's shown in the C#
snippet above.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
Thanks for the information. That's what I was afraid of. Do you have any
suggestions for a workaround in VB.Net 2003? Is there some way I can detect
if an event handler is attached or detached?

Thanks again.

"Herfried K. Wagner [MVP]" wrote:
"Luhar" <Lu***@discussions.microsoft.com> schrieb:
I'm attempting to port some C# code over to VB.Net. It was going well
until
I hit the following code:

public virtual event PInputEventHandler KeyDown {
add { handlers.AddHandler(keyDownEventKey, value); }
remove { handlers.RemoveHandler(keyDownEventKey, value); }
}

It appears that one can declare Add and Remove accessors within an event
declaration in C#. Is there any way to do this in VB.Net?


In currently released final versions of VB.NET, there is no way to do that.
VB 2005 will include a similar way to archieve what's shown in the C#
snippet above.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

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

Similar topics

22
by: mirandacascade | last post by:
When I look at how classes are set up in other languages (e.g. C++), I often observe the following patterns: 1) for each data member, the class will have an accessor member function (a...
3
by: LuCk | last post by:
Can someone explain what these really are for example: ---------------------------------------------------------- void SetFrameRate(int iFrameRate) { m_iFrameDelay = 1000 / iFrameRate; }; ...
10
by: ma740988 | last post by:
I'm hoping my post here doesn't fall into the 'hard to say' category, nonetheless I've been advised that multiple uses of accessor/mutator (get/set) member functions can be viewed as a 'design...
1
by: Pol Bawin | last post by:
Hi, I have a objectA with a property that return an object B (accessor GET only) I have defined an ExpandableObjectConverter on the type B and overrided CanConvertTo, CanConvertFrom, ... The...
6
by: Jason Shohet | last post by:
I have a class with protected variables and some accessor methods, , get, set ... Maybe I have a brain blockage today but I'm thinking, why not just make those variables public. After all,...
11
by: Kavvy | last post by:
How come a lot of the examples I have seen on the net define accessor pairs within a class, and then only ever use the accessor outside the class? When used within the class the variable is...
7
by: Javaman59 | last post by:
This is probably common knowledge to .Net gurus, but please bear with me while I share a discovery with the group... I needed to create a public lock on a class, as follows... class Locked {...
7
by: Tenacious | last post by:
I have been programming using C# for over a year now and I still wonder what is the importance of using accessor methods when the property is read-write. It seems easier to just make it a public...
3
by: steve | last post by:
Hi all, I want to be able to hirearchally define event delegate (declarations) WITHIN interfaces. Unfortunatelly C# 1 doesn't appear to support it. How does the following look as a...
15
by: jmDesktop | last post by:
Consider: <?php echo "start"; class myClass { public $connection;
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.