469,362 Members | 2,546 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,362 developers. It's quick & easy.

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 1923
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by ZŁrcher See | last post: by
7 posts views Thread by TiŽsto | last post: by
14 posts views Thread by Arne | last post: by
3 posts views Thread by AMerrell | last post: by
2 posts views Thread by Nathan | last post: by
6 posts views Thread by Larry Minton | last post: by
15 posts views Thread by Gustaf | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.