NeuralJack
Centurion
- Joined
- Jul 28, 2005
- Messages
- 138
I'm trying to convert a C# class into VB.net and have come up with a problem.
The C# code is:
And I would have guessed the VB.net equivalent is:
But that does not work. The error message is "... is an event and can not be called directly."
It's obviously some difference in the syntax in the way events are handled. I know that in C# you can call an event much like a function, but in VB.net you must use RaiseEvent. But upon further research I can not find a way to check for an event's instantiation in a conditional statement.
Thanks for any help
The C# code is:
Code:
public event MouseEventHandler OnMouseActivity;
public void MySub()
{
if (OnMouseActivity != null)
{
}
}
And I would have guessed the VB.net equivalent is:
Code:
Public Event OnMouseActivity As MouseEventHandler
Public Sub MySub()
If OnMouseActivity isnot Nothing Then
End If
End Sub
But that does not work. The error message is "... is an event and can not be called directly."
It's obviously some difference in the syntax in the way events are handled. I know that in C# you can call an event much like a function, but in VB.net you must use RaiseEvent. But upon further research I can not find a way to check for an event's instantiation in a conditional statement.
Thanks for any help