473,407 Members | 2,546 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,407 software developers and data experts.

Conversion to vb.net

could someone please help me convert this c# code to vb.net

public event EventHandler TextChanged {
add {
Events.AddHandler(EventTextChanged, value);
}
remove {
Events.RemoveHandler(EventTextChanged, value);
}
}
Nov 17 '05 #1
12 1423
Hi,

Where you got this code from?

That's not c# code

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"NEWBIE" <NE****@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
could someone please help me convert this c# code to vb.net

public event EventHandler TextChanged {
add {
Events.AddHandler(EventTextChanged, value);
}
remove {
Events.RemoveHandler(EventTextChanged, value);
}
}

Nov 17 '05 #2
<"Ignacio Machin \( .NET/ C# MVP \)" <ignacio.machin AT
dot.state.fl.us>> wrote:
Where you got this code from?

That's not c# code


What makes you say that? It looks okay to me, assuming that Events and
EventTextChanged are appropriately defined.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #3
Actually, it is C# code. I can get something very similar to compile in VS
2003.
However, I can't find anything on MSDN about this and I could only find a
couple of references in google to "explicit event declaration" in C#. We
regularly test our converters on over 200 sample programs from Microsoft and
other sources and have yet to encounter anyone using this event declaration
form.

Also, nothing in VS help. The keywords "add" and "remove" are not even
keywords in C#. Very strange. (but we will be updating our Instant VB C# to
VB converter to deal with this).

Regards,
David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter and the Instant VB C# to
VB.NET converter

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Where you got this code from?

That's not c# code

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"NEWBIE" <NE****@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
could someone please help me convert this c# code to vb.net

public event EventHandler TextChanged {
add {
Events.AddHandler(EventTextChanged, value);
}
remove {
Events.RemoveHandler(EventTextChanged, value);
}
}


Nov 17 '05 #4
They're called event accessors. There's a bit on them in MSDN, and a bit
more in Hejlsberg's C# book. I can't remember the syntax, but they'll be in
VB.NET 2005 as well.

"David Anton" <Da********@discussions.microsoft.com> wrote in message
news:EC**********************************@microsof t.com...
Actually, it is C# code. I can get something very similar to compile in VS
2003.
However, I can't find anything on MSDN about this and I could only find a
couple of references in google to "explicit event declaration" in C#. We
regularly test our converters on over 200 sample programs from Microsoft
and
other sources and have yet to encounter anyone using this event
declaration
form.

Also, nothing in VS help. The keywords "add" and "remove" are not even
keywords in C#. Very strange. (but we will be updating our Instant VB C#
to
VB converter to deal with this).

Regards,
David Anton
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter and the Instant VB C# to
VB.NET converter

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Where you got this code from?

That's not c# code

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"NEWBIE" <NE****@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
> could someone please help me convert this c# code to vb.net
>
> public event EventHandler TextChanged {
> add {
> Events.AddHandler(EventTextChanged, value);
> }
> remove {
> Events.RemoveHandler(EventTextChanged, value);
> }
> }


Nov 17 '05 #5
David Anton <Da********@discussions.microsoft.com> wrote:
Actually, it is C# code. I can get something very similar to compile in VS
2003.
However, I can't find anything on MSDN about this and I could only find a
couple of references in google to "explicit event declaration" in C#. We
regularly test our converters on over 200 sample programs from Microsoft and
other sources and have yet to encounter anyone using this event declaration
form.
I use it and advocate it, personally. The default way of handling
events locks "this" in C# (at least with the current MS compiler) which
I believe to be a bad idea.

See http://www.yoda.arachsys.com/csharp/...ckchoice.shtml for my
reasons and a better event pattern.
Also, nothing in VS help. The keywords "add" and "remove" are not even
keywords in C#. Very strange. (but we will be updating our Instant VB C# to
VB converter to deal with this).


It's in section 17.7.1 and 17.7.2 of the C# language specification
(ECMA numbering).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #6

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
[Snip]
The default way of handling
events locks "this" in C# (at least with the current MS compiler) which
I believe to be a bad idea.
Really? Hmph, I think I agree with you.
See http://www.yoda.arachsys.com/csharp/...ckchoice.shtml for my
reasons and a better event pattern.


Nice, I esp like the copying of the delegate in the lock. Elegant.
Nov 17 '05 #7
Thanks for the references Jon.
I wonder why coverage on it is so hard to find in most references?
I'm familiar with the general concept from C++...

I'm especially puzzled about why "add" and "remove" aren't even keywords !

"Jon Skeet [C# MVP]" wrote:
David Anton <Da********@discussions.microsoft.com> wrote:
Actually, it is C# code. I can get something very similar to compile in VS
2003.
However, I can't find anything on MSDN about this and I could only find a
couple of references in google to "explicit event declaration" in C#. We
regularly test our converters on over 200 sample programs from Microsoft and
other sources and have yet to encounter anyone using this event declaration
form.


I use it and advocate it, personally. The default way of handling
events locks "this" in C# (at least with the current MS compiler) which
I believe to be a bad idea.

See http://www.yoda.arachsys.com/csharp/...ckchoice.shtml for my
reasons and a better event pattern.
Also, nothing in VS help. The keywords "add" and "remove" are not even
keywords in C#. Very strange. (but we will be updating our Instant VB C# to
VB converter to deal with this).


It's in section 17.7.1 and 17.7.2 of the C# language specification
(ECMA numbering).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 17 '05 #8
"David Anton" <Da********@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com...
Thanks for the references Jon.
I wonder why coverage on it is so hard to find in most references?
I'm familiar with the general concept from C++...

I'm especially puzzled about why "add" and "remove" aren't even keywords !
It' this whole contextual keywod thing I'd guess, sorta like how "yield"
won't be a keyword in Whidbey.

"Jon Skeet [C# MVP]" wrote:
David Anton <Da********@discussions.microsoft.com> wrote:
> Actually, it is C# code. I can get something very similar to compile in
> VS
> 2003.
> However, I can't find anything on MSDN about this and I could only find
> a
> couple of references in google to "explicit event declaration" in C#.
> We
> regularly test our converters on over 200 sample programs from
> Microsoft and
> other sources and have yet to encounter anyone using this event
> declaration
> form.


I use it and advocate it, personally. The default way of handling
events locks "this" in C# (at least with the current MS compiler) which
I believe to be a bad idea.

See http://www.yoda.arachsys.com/csharp/...ckchoice.shtml for my
reasons and a better event pattern.
> Also, nothing in VS help. The keywords "add" and "remove" are not even
> keywords in C#. Very strange. (but we will be updating our Instant VB
> C# to
> VB converter to deal with this).


It's in section 17.7.1 and 17.7.2 of the C# language specification
(ECMA numbering).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 17 '05 #9
:-)

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Where you got this code from?
:-) It sure is c# code my friend. Try Asp.net controls by micrososft press
Nikhil Kothari Chapter 9 That's not c# code

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"NEWBIE" <NE****@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com...
could someone please help me convert this c# code to vb.net

public event EventHandler TextChanged {
add {
Events.AddHandler(EventTextChanged, value);
}
remove {
Events.RemoveHandler(EventTextChanged, value);
}
}


Nov 17 '05 #10
David Anton <Da********@discussions.microsoft.com> wrote:
Thanks for the references Jon.
I wonder why coverage on it is so hard to find in most references?
I'm familiar with the general concept from C++...
I suspect many C# programmers only use the "event variable" type
pattern, without really thinking about it, unfortunately :(
I'm especially puzzled about why "add" and "remove" aren't even keywords !


As Sean says, I think it's because they don't need to be.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #11
Its called Event Property Construct. Someone rightly said its not there
vb.net but will be there in 2005
The way you use this in Vb.NET is

AddHandler Me.TextChanged, AddressOf EventTextChanged
RemoveHandler Me.TextChanged, AddressOf EventTextChanged

Thanx for yr replies. The code is from Nikhil Kothari's Best seller ASP.NET
controls book.
"NEWBIE" wrote:
could someone please help me convert this c# code to vb.net

public event EventHandler TextChanged {
add {
Events.AddHandler(EventTextChanged, value);
}
remove {
Events.RemoveHandler(EventTextChanged, value);
}
}

Nov 17 '05 #12
Hi Jon,

Long time, no see. :)

You are right, I have to be honest and say that this is the first time I see
such a declaration before.

You always learn something new :)

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
<"Ignacio Machin \( .NET/ C# MVP \)" <ignacio.machin AT
dot.state.fl.us>> wrote:
Where you got this code from?

That's not c# code


What makes you say that? It looks okay to me, assuming that Events and
EventTextChanged are appropriately defined.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 17 '05 #13

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

Similar topics

1
by: Stub | last post by:
Docs says that "The compiler does not use an explicit constructor to implement an implied conversion of types. It's purpose is reserved explicitly for construction." I put up code of three cases...
7
by: Michael Lehn | last post by:
Hi, I have a question regarding the conversion of objects. When is the conversion done by the constructor and when by the operator. My feeling tells me that the constructor is preferred. But...
16
by: TTroy | last post by:
Hello, I'm relatively new to C and have gone through more than 4 books on it. None mentioned anything about integral promotion, arithmetic conversion, value preserving and unsigned preserving. ...
31
by: Bjørn Augestad | last post by:
Below is a program which converts a double to an integer in two different ways, giving me two different values for the int. The basic expression is 1.0 / (1.0 * 365.0) which should be 365, but one...
11
by: Steve Gough | last post by:
Could anyone please help me to understand what is happening here? The commented line produces an error, which is what I expected given that there is no conversion defined from type double to type...
2
by: Alex Sedow | last post by:
Why explicit conversion from SomeType* to IntPtr is not ambiguous (according to standart)? Example: // System.IntPtr class IntPtr { public static explicit System.IntPtr (int); public...
3
by: Steve Richter | last post by:
here is a warning I am getting in a C++ .NET compile: c:\SrNet\jury\JuryTest.cpp(55) : warning C4927: illegal conversion; more than one user-defined conversion has been implicitly applied while...
0
by: Lou Evart | last post by:
DOCUMENT CONVERSION SERVICES Softline International (SII) operates one of the industry's largest document and data conversion service bureaus. In the past year, SII converted over a million...
0
by: dataentryoffshore | last post by:
Get a Discount up to 60% on data entry, data capture, dataentry services, large volume data processing and data conversion services through offshore facilities in India. Offshore data entry also...
21
by: REH | last post by:
It it permissible to use the constructor style cast with primitives such as "unsigned long"? One of my compilers accepts this syntax, the other does not. The failing one chokes on the fact that the...
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...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
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.