472,805 Members | 2,117 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 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 2060
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.