473,385 Members | 1,780 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.

C# to VB.NET IClonable

Hello,

There is a C# funciton I'm trying to translate that clones some event handlers.

public virtual object Clone()
{
...... Instance of a Custom Collection .......
myCol.ItemAdded = this.ItemAdded;
myCol.ItemRemoved = this.ItemRemoved;
return myCol;
}

In VB.NET I have this.

Public Overridable Function Clone() As Object Implements ICloneable.Clone
...... Instance of a Custom Collection .......
myCol.ItemAdded = me.ItemAdded
myCol.ItemRemoved = me.ItemRemoved
return myCol
End Function

The system tells me I need to use a 'RaiseEvent' statement to raise an event.

How do I go about doing the same thing in VB.NET that was done in C#?

Thank You
AM

Jul 21 '05 #1
3 2082
Use this
AddHandler myCol.ItemAdded, AddressOf me.ItemAdded


"AMerrell" <an*******@msnews.microsoft.com> wrote in message
news:e7**************@TK2MSFTNGP12.phx.gbl...
Hello,

There is a C# funciton I'm trying to translate that clones some event
handlers.

public virtual object Clone()
{
...... Instance of a Custom Collection .......
myCol.ItemAdded = this.ItemAdded;
myCol.ItemRemoved = this.ItemRemoved;
return myCol;
}

In VB.NET I have this.

Public Overridable Function Clone() As Object Implements ICloneable.Clone
...... Instance of a Custom Collection .......
myCol.ItemAdded = me.ItemAdded
myCol.ItemRemoved = me.ItemRemoved
return myCol
End Function

The system tells me I need to use a 'RaiseEvent' statement to raise an
event.

How do I go about doing the same thing in VB.NET that was done in C#?

Thank You
AM


Jul 21 '05 #2
Hi,

AddHandler myCol.ItemAdded, AddressOf Me.ItemAdded gives me 'AdressOf' operand must be the name of a method; no parantheses are needed.
Not sure why it mentions parantheses since the are none.

Thanks,
AM
Jul 21 '05 #3
Because Me.ItemAdded must be a sub or a function.
myCol.ItemAdded must be an event declaration.
Public Class Col

Public Event ItemAdded()

End Class

Public Class Clones

Sub ItemAdded()

End Sub

Function Clone() as Object

....

AddHandler myCol.ItemAdded, me.ItemAdded

return myCol

End Function

End Class

"AMerrell" <an*******@msnews.microsoft.com> wrote in message
news:ed**************@tk2msftngp13.phx.gbl...
Hi,

AddHandler myCol.ItemAdded, AddressOf Me.ItemAdded gives me 'AdressOf'
operand must be the name of a method; no parantheses are needed.
Not sure why it mentions parantheses since the are none.

Thanks,
AM


Jul 21 '05 #4

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

Similar topics

5
by: Zürcher See | last post by:
If I want to implement an IClonable interface, how can I copy the events from my source object to the target "cloned" object?
7
by: Tiësto | last post by:
Hi everybody. I know everyone has said to me that this doesn't exist but I'm going to try anyway. I have an instance of ClassA and I want to duplicate that instance, creating another one that is...
1
by: oDDskOOL | last post by:
I realized today that the Hashtable.Clone only produces a shallow copy... that makes me go mad that M$ doesn't even provide a deep copy ctor for the Hashtable class ! mighty tech ducks might...
14
by: Arne | last post by:
In C++ we have a copy constructor. What is the equivalent in .Net? Would that be a clone method?
3
by: AMerrell | last post by:
Hello, There is a C# funciton I'm trying to translate that clones some event handlers. public virtual object Clone() { ...... Instance of a Custom Collection ....... myCol.ItemAdded =...
2
by: Nathan | last post by:
I'm working with Clone() for the first time, and noticed that you have to unbox the Clone of an object that implements ICloneable: MyObject var1 = new MyObject(); // Where MyObject implements...
6
by: Larry Minton | last post by:
Is there a C++ method comparable to the vb.net TryCast function? I had hopes for Convert::ChangeType, but that didn't work. For a scripting engine, the user is specifying to retrieve an...
2
by: bonk | last post by:
I have come across the need to distinguish between the creation of a deep and a shallow copy and with great interest I have read this article: ...
15
by: Gustaf | last post by:
Using VS 2005. I got an 'IpForm' class and an 'IpFormCollection' class, containing IpForm objects. To iterate through IpFrom objects with foreach, the class is implemented as such: public class...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.