terrydiederich2
1/10/2019 - 3:08 PM

Events Example 2

Events Example using Custom EventArgs class

' Class that fires the event

Public Class ucProductBOM
    ....
    Public Event BOMCostChanged(ByVal sender As Object, ByVal e As BomCostEventArgs)
    ....
    
    Private Sub SomeRoutine()
        ....
        Dim args As New BomCostEventArgs(mBOMCost)
        RaiseEvent BOMCostChanged(Me, args)
        ....    
    End Sub

End Class

' Event Args Class
Public Class BomCostEventArgs
        Inherits System.EventArgs

    Public BOMCost As Decimal

    Public Sub New(ByVal _bomCost As Decimal)
        MyBase.New
        BOMCost = _bomCost
    End Sub
End Class
    
    
' Class that handles the event    

....
Private Sub BomCostChangedHandler(sender As Object, e As ucProductBOM.BomCostEventArgs) Handles UcProductBOM1.BOMCostChanged
    Me.UcProductDetail1.UpdateBOMCost(e.BOMCost)
End Sub    
....