T
Tom Shelton
Hello. In project Visual Studio 2008, Visual C#, Windows Forms Application,
I have written down such code on C# without errors:
public class UiButton
{
public event EventHandler Click;
public void OnMouseClick(int x, int y)
{
if (Click != null)
Click(this, EventArgs.Empty);
}
}
The same code, I have copied in the project Visual Studio 2008, Visual
Basic, Windows Forms Application in such kind on Visual Basic:
Public Class UiButton
Public Event Click As EventHandler
Public Sub OnMouseClick(ByVal x As Integer, _
ByVal y As Integer)
If (RaiseEvent Click <> Nothing) Then
RaiseEvent Click(Me, EventArgs.Empty)
End If
End Sub
End Class
The compiler is emphasized the first RaiseEvent statement and gives out the
message on this error:
Expression expected.
Inform, please, how correctly to write down this code on Visual Basic?
Many thanks, Zharkov, Moskva, Rossiya.
You don't need to test the delegate for nothing in VB.NET the
RaiseEvent statement will do it for you...
Public Class UiButton
Public Event Click As EventHandler
Public Sub OnMouseClick(ByVal x As Integer, _
ByVal y As Integer)
RaiseEvent Click(Me, EventArgs.Empty)
End Sub
End Class
HTH