How to use an instance of the class WithEvents and RaiseEvent from the class in VB.NET

1 Answer

0 votes
Module Module1

    WithEvents ECT As New EventClassTest

    Sub Print1() Handles ECT.EventTest
        Console.WriteLine("Print1()")
    End Sub

    Sub Print2() Handles ECT.EventTest
        Console.WriteLine("Print2()")
    End Sub

    Sub Print3() Handles ECT.EventTest
        Console.WriteLine("Print3()")
    End Sub

    Sub Main()

        ECT.RaiseEvents()

    End Sub

    Class EventClassTest
        Public Event EventTest()
        Sub RaiseEvents()
            RaiseEvent EventTest()
        End Sub
    End Class

End Module

' run:
' 
' Print1()
' Print2()
' Print3()

 



answered Oct 20, 2018 by avibootz

Related questions

2 answers 229 views
229 views asked Feb 1, 2017 by avibootz
1 answer 166 views
1 answer 116 views
1 answer 171 views
...