2
Answers

Converting from C# to VB problem

Photo of Carol Markham

Carol Markham

14y
2.3k
1

Hi,
I am converting a mobile app from C# to VB. My problem is with clicking on a menuItem.
The original C# code for the _Click is as follows:
        private void mnuItmQuit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

Which I have converted as this:
Private Sub mnuItmQuit_Click(ByVal sender As Object, ByVal e As EventArgs)

Application.[Exit]()
End Sub
Further down the generated Forms code for mnuItmQuit is:
Me.mnuItmQuit.Text = "Quit"
Me
.mnuItmQuit.Click += New System.EventHandler(AddressOf Me.mnuItmQuit_Click)
However, I get this error: "Public Event Click(sender As Object, e As System.EventArgs" is an event and cannot be called directly. Use a RaiseEvent statement to raise an event.
At this point, I'm lost and have no idea where or how to do the RaiseEvent.
Thanks in advance. 

Answers (2)

0
Photo of Crish
NA 3.7k 76.4k 14y
Hi

If you are doing these things in vb.net code then you can use conveter for  Converting from C# to VB problem.

To convert the code please follow this link

http://www.developerfusion.com/tools/convert/csharp-to-vb/
0
Photo of Jiteendra Sampathirao
NA 6.9k 1.5m 14y
Hi,

If you are doing these things in vb.Net code behind you can see the classes, methods and events on the top of the coding page.
There you can see the button id as mnuItmQuit in left side dropdownlist and those events and methods are in right dropdownlist.
So select the button id and go for the events which are existed in right Dropdownlist.

Then you can see the code in coding page like this:

 Protected Sub
mnuItmQuit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuItmQuit.Click
//Your code goes here
End sub

--------------------------------------------------------------------------------------------------------------------------------
If this post helped you, then tick the "Do you like this Answer" checkbox which is placed at above this post.