As
NotPolitcallyCorrect[
^] mentioned in the comment to the question, you have to use
EventArgs Class (System)[
^]. At the bottom of related page you'll find an example.
[EDIT]
Here is a code sample which uses your class:
Public Sub ctv_DataHasBeenAdded(sender As Object, e As ClassTimerVarsEventArgs)
Console.WriteLine("New data has been added! Feedrate: {0}, Spindle: {1}, Rapid: {2}.", e.Feedrate, e.Spindle, e.Rapid)
Dim c As ClassTimerVars = DirectCast(sender, ClassTimerVars)
Console.WriteLine(c.ToString())
End Sub
Public Class ClassTimerVars
Private _Feedrate As Integer
Private _Spindle As Integer
Private _Rapid As Integer
Public Sub New()
End Sub
Public Sub New(iFeedrate As Integer, iSpindle As Integer, iRapid As Integer)
_Feedrate = iFeedrate
_Spindle = iSpindle
_Rapid = iRapid
End Sub
Public Property Feedrate() As Integer
Get
Feedrate = _Feedrate
End Get
Set(ByVal value As Integer)
_Feedrate = value
End Set
End Property
Public Property Spindle() As Integer
Get
Spindle = _Spindle
End Get
Set(ByVal value As Integer)
_Spindle = value
End Set
End Property
Public Property Rapid() As Integer
Get
Rapid = _Rapid
End Get
Set(ByVal value As Integer)
_Rapid = value
End Set
End Property
Public Overrides Function ToString() As String
Return String.Format("ClassTimerVars totals - Feedrate: {0}, Spindle: {1}, Rapid: {2}.", _Feedrate, _Spindle, _Rapid)
End Function
Public Sub AddData(ByVal iFeedrate As Integer, ByVal iSpindle As Integer, ByVal iRapid As Integer)
_Feedrate += iFeedrate
_Spindle += iSpindle
_Rapid += iRapid
Dim args As ClassTimerVarsEventArgs = New ClassTimerVarsEventArgs() _
With {.Feedrate = iFeedrate, .Spindle = iSpindle, .Rapid = iRapid}
OnDataAdded(args)
End Sub
Protected Overridable Sub OnDataAdded(e As ClassTimerVarsEventArgs)
RaiseEvent DataHasBeenAdded(Me, e)
End Sub
Public Event DataHasBeenAdded As EventHandler(Of ClassTimerVarsEventArgs)
End Class
Public Class ClassTimerVarsEventArgs
Inherits EventArgs
Public Property Feedrate As Integer
Public Property Spindle As Integer
Public Property Rapid As Integer
End Class
Usage:
Sub Main
Dim ctv As ClassTimerVars = New ClassTimerVars(1,5,10)
AddHandler ctv.DataHasBeenAdded, AddressOf ctv_DataHasBeenAdded
Console.WriteLine(ctv.ToString())
ctv.AddData(2,8,11)
ctv.AddData(Nothing,3,21)
ctv.AddData(12,4,Nothing)
End Sub
Output:
ClassTimerVars totals - Feedrate: 1, Spindle: 5, Rapid: 10.
New data has been added! Feedrate: 2, Spindle: 8, Rapid: 11.
ClassTimerVars totals - Feedrate: 3, Spindle: 13, Rapid: 21.
New data has been added! Feedrate: 0, Spindle: 3, Rapid: 21.
ClassTimerVars totals - Feedrate: 3, Spindle: 16, Rapid: 42.
New data has been added! Feedrate: 12, Spindle: 4, Rapid: 0.
ClassTimerVars totals - Feedrate: 15, Spindle: 20, Rapid: 42.
Try!