Click here to Skip to main content
15,908,264 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Ok, I've been searching online for almost 6 Hrs and Gave up on this.

I used a code snippet from a Website to create a Small C# Application.

I am learning to do the same in VB.net and finally ended up writing below ( Actually Converting C# to VB.NET)

VB
Private Sub btnSearch_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles btnSearch.Click, btnSearch.Tap
Dim MyClient As New PatDemoService.GetPatDemoClient
MyClient.GetPatDemoCompleted += New EventHandler(Of GetPatDemoCompletedEventArgs)(AddressOf MyClient_GetPatDemoCompleted)
MyClient.GetPatDemoAsync(TextBox1.Text)
End Sub

Private Sub MyClient_GetPatDemoCompleted(sender As Object, e As GetPatDemoCompletedEventArgs)
lbPatData.ItemsSource = e.Result
End Sub


After conversion, I Get an error Here( on the line where it is bold). Error says

'Public Event GetPatDemoCompleted(sender As Object, e As PatDemoService.GetPatDemoCompletedEventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.

Can someone Help me out on this?
Posted

You did not show the source (C#) code, so I cannot check it up. You also did not provide a reference to the translator. Some of the on-line translators are better than others.

Besides, if you can spend a bit more time on compilation and decompilation, there is a high-quality open-source off-line option, ILSpy.

Please see my past answers:
FixedPage to ContentPage convert c# code into vb.net[^],
Need to convert vb code to c#[^].

—SA
 
Share this answer
 
Many C# to VB converters fail to translate the wiring up of event handlers properly.

Based on your indicate line of:

MyClient.GetPatDemoCompleted += New EventHandler(Of GetPatDemoCompletedEventArgs)(AddressOf MyClient_GetPatDemoCompleted)


I would guess that it should been translated to:

Addhandler MyClient.GetPatDemoCompleted, Addressof MyClient_GetPatDemoCompleted
 
Share this answer
 

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