2
Answers

Converting from C# to VB problem

Ask a question
Carol Markham

Carol Markham

13y
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)