Can someone convert this to VB .NET? I tried this, but it didn't work.Code:Dim Mycls as New MyClass
Mycls.MyEvent += new MyClass.MyEventHandler(Mycls_MyEvent);
Printable View
Can someone convert this to VB .NET? I tried this, but it didn't work.Code:Dim Mycls as New MyClass
Mycls.MyEvent += new MyClass.MyEventHandler(Mycls_MyEvent);
vb Code:
AddHandler Mycls.MyEvent, AddressOf MyClass.MyEventHandler()
Technically it would be:but that can be simplified to:Code:AddHandler Mycls.MyEvent, New MyClass.MyEventHandler(AddressOf Mycls_MyEvent)
just as the C# code can be simplified to:Code:AddHandler Mycls.MyEvent, AddressOf Mycls_MyEvent
Code:Mycls.MyEvent += Mycls_MyEvent;
Error 1 Expression does not produce a value.Code:AddHandler Mycls.MyEvent, AddressOf Mycls_MyEvent(sender, e)
Um, look at what you just posted and look at what I posted. Are they the same?
Warning 1 Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated.Code:AddHandler Mycls.MyEvent...
Didn't we discuss this in your other thread? How do you access a Shared member? Via the type itself, not an instance of the type. Do you do this?No, you don't. You do this:Code:Dim mb As New MessageBox
mb.Show("Hello World")
This is exactly the same. MyClass is a type and MyEvent is a Shared member of that type, so you access MyEvent via MyClass, not an instance of MyClass.Code:MessageBox.Show("Hello World")