Conversion from C#
Visual Basic
1
Posts
1
Posters
0
Views
1
Watching
-
Dear all :-) I converted a sample from C# to VB and get an error message. It looks simple, but still I don't understand... Would it be possible that C# allows calling an event directly, while VB doesn't? Or did my conversion tool go wrong? Here's the short sample code:
private void OnWaveControlContextMenuPopup(ContextMenu menu) { if (this.WControlContextMenuPopup == null) return; this.WControlContextMenuPopup(menu); }
where WControlContextMenuPopup is defined as an event:
public event WControlContextMenuPopupDelegate WaveControlContextMenuPopup;
After conversion I get the error message "Public Event WControlContextMenuPopup in an event and cannot be called directly. Use 'RaiseEvent'...". The error is shown in lines 2 and 5 of the converted code:
Private Sub OnWControlContextMenuPopup(menu As ContextMenu) If Me.WControlContextMenuPopup Is Nothing Then <----- Return End If Me.WControlContextMenuPopup(menu) <----- End Sub
What would I have to change in the VB code to get the required result without error? Thanks for some insight... Mick