Event Handling in VB.Net + Late Binding

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Elankathir S.N.

    #1

    Event Handling in VB.Net + Late Binding

    I Created Object A in the Object B. then I called a function of object
    A from object B…
    Like..

    Public Class A

    Public Event beforeSample()

    Public Sub function_Sample ()

    RaiseEvent beforeSample()

    ‘’’’’’
    ‘’’’’’
    ‘’’’’’
    End Function

    End Class

    Public Class B

    Private WithEvents obj as new A

    Private Function Main() as Boolean
    ‘’’’’’
    ‘’’’’
    ‘’’’’
    ‘’’’’
    Obj. function_Sample ()
    ‘’’’’
    ‘’’’’
    ‘’’’’
    ‘’’’’
    End function


    Private Sub obj_beforeSampl e() handle Obj.beforeSampl e

    End Sub

    End Class

    So here I handle the event beforeSample in the Object B….!

    The Problem is… How do I handle the events, if I create the object in
    late bind method ?

    means…

    Public Class B

    Private obj as Object

    Private Function Main() as Boolean

    ‘’’’’’
    ‘’’’’’
    ‘’’’’’
    obj = new A ‘late bind method

    ‘’’’’’
    ‘’’’’’
    ‘’’’’’
    Obj. function_Sample ()

    End Function

    End Class

    Then How to handle the events of Object A ??



    *** Sent via Developersdex http://www.developersdex.com ***
  • Ken Tucker [MVP]

    #2
    Re: Event Handling in VB.Net + Late Binding

    Hi,

    Use AddHandler
    http://msdn2.microsoft.com/en-us/library/6yyk8z93.aspx

    Ken
    ----------------------
    "Elankathir S.N." <snelankathir@h otmail.comwrote in message
    news:OyQMkgWsGH A.1580@TK2MSFTN GP05.phx.gbl...
    >I Created Object A in the Object B. then I called a function of object
    A from object B.
    Like..
    >
    Public Class A
    >
    Public Event beforeSample()
    >
    Public Sub function_Sample ()
    >
    RaiseEvent beforeSample()
    >
    ''''''
    ''''''
    ''''''
    End Function
    >
    End Class
    >
    Public Class B
    >
    Private WithEvents obj as new A
    >
    Private Function Main() as Boolean
    ''''''
    '''''
    '''''
    '''''
    Obj. function_Sample ()
    '''''
    '''''
    '''''
    '''''
    End function
    >
    >
    Private Sub obj_beforeSampl e() handle Obj.beforeSampl e
    >
    End Sub
    >
    End Class
    >
    So here I handle the event beforeSample in the Object B..!
    >
    The Problem is. How do I handle the events, if I create the object in
    late bind method ?
    >
    means.
    >
    Public Class B
    >
    Private obj as Object
    >
    Private Function Main() as Boolean
    >
    ''''''
    ''''''
    ''''''
    obj = new A 'late bind method
    >
    ''''''
    ''''''
    ''''''
    Obj. function_Sample ()
    >
    End Function
    >
    End Class
    >
    Then How to handle the events of Object A ??
    >
    >
    >
    *** Sent via Developersdex http://www.developersdex.com ***

    Comment

    Working...