본문 바로가기
카테고리 없음

[VB.NET] program that uses WithEvents, Handles

by IT HUB 2021. 3. 10.
728x90
반응형
Module Module1
 
    ' An instance of the Event class.
    WithEvents EventClassInstance As New EventClass
 
    Sub PrintTestMessage() Handles EventClassInstance.TestEvent
        ' This method handles the TestEvent.
        Console.WriteLine("Test Message Being Printed...")
    End Sub
 
    Sub PrintTestMessage2() Handles EventClassInstance.TestEvent
        ' This method also handles the event.
        Console.WriteLine("Test Message 2 Being Printed...")
    End Sub
 
 
    Sub Main()
        ' Call into the Event class and raise the test events.
        EventClassInstance.RaiseEvents()
    End Sub
 
    Class EventClass
        Public Event TestEvent()
        Sub RaiseEvents()
            ' Raise the Test event.
            ' ... This needs to be part of the class with the Event.
            RaiseEvent TestEvent()
        End Sub
    End Class
 
End Module
반응형

댓글