i converted a c# class to vb net, but there are some events that couldnt find out these are the delegates declarations:
Public Delegate Sub IndentChangedEventHandler(NewValue As Integer)
Public Delegate Sub MultiIndentChangedEventHandler(LeftIndent As Integer, HangIndent As Integer)
Public Delegate Sub MarginChangedEventHandler(NewValue As Integer)
Public Delegate Sub TabChangedEventHandler(args As TabEventArgs)
Public Event LeftHangingIndentChanging As IndentChangedEventHandler
Public Event LeftIndentChanging As IndentChangedEventHandler
Public Event RightIndentChanging As IndentChangedEventHandler
Public Event BothLeftIndentsChanged As MultiIndentChangedEventHandler
Public Event LeftMarginChanging As MarginChangedEventHandler
Public Event RightMarginChanging As MarginChangedEventHandler
Public Event TabAdded As TabChangedEventHandler
Public Event TabRemoved As TabChangedEventHandler
Public Event TabChanged As TabChangedEventHandler
‘this is the function converted on vb net
Private Sub AddTab(pos As Single)
Dim rect As New RectangleF(pos, 10.0F, 8.0F, 8.0F)
tabs.Add(rect)
If TabAdded IsNot Nothing Then
TabAdded.Invoke(CreateTabArgs(pos))
End If
End Sub
the sentence on c# was
if (TabAdded != null)
TabAdded.Invoke(CreateTabArgs(pos));
what should it be the correct way to call the delegate?
Events have three accessors in vb.net: add, remove and raise. C# doesn’t support the raise accessor so you have to explicitly test for null. That is not necessary in vb.net, and not allowed, just use the RaiseEvent statement directly without testing for Nothing: