Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
myNetwork.IterationChanged += New NeuralNetwork(Of 
String).IterationChangedCallBack(neuralNetwork_IterationChanged)


it says that it cannot be called directly. it needs to use raise event statement to raise an event. can someone help me..i cant figure out on how to handle events in visual basic,,
Posted

MSDN[^] suggests:

AddHandler myNetwork.IterationChanged, AddressOf neuralNetwork_IterationChanged
 
Share this answer
 
It looks like you don't know what the event is. Please read on events in VB.NET and .NET manual. An event can only be raised in the class where it is declared. This is one of the important limitations of events compared to regular delegate instances.

Your situation cannot be "fixed". You need to explain what you want to achieve to get suggestion on some solution.

—SA
 
Share this answer
 
Comments
Simon_Whale 2-Jul-11 20:49pm    
The event statement that the OP posted is a C# event handler. Most C# to VB converts that I have used in the past don't convert event handlers at all.

Which leads me to believe that he has used a converter to translate some code and hoped that it does it verbatim
Sergey Alexandrovich Kryukov 3-Jul-11 2:34am    
Are you saying the auto-translation for C# to VB.NET ignores events or just incorrectly translate? Well, you don't say VB.NET cannot be written with events in the same way, right? It would be an absurd.

Well, don't you think my answer remains correct anyway?
--SA
Simon_Whale 3-Jul-11 4:52am    
VB.NET and C# events are handled in the same way but are written differently. The answer from OriginalGriff is how VB.NET events are programatically written. The original Poster has posted a C# event.

In regards to your question It would appear that the OP hasn't yet learnt about event handling and would benifit from some reading on the subject, so your answer would be correct to the point that you have stated.

auto-translation applications doesn't translate the events from C# to VB.NET they leave it as C#.
Sergey Alexandrovich Kryukov 3-Jul-11 16:27pm    
Thank you. Sure. At to the auto-translation applications you refer, this problem should be considered as a bug.
--SA
Dave Kreskowiak 5-Jul-11 15:52pm    
Not really. There's just no way to do it reliably. If you look at the IL for the C# app, it looks no different than any other += operation. There's no way to know that the result should, or should NOT, be written as AddHandler in VB.NET.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900