We help IT Professionals succeed at work.

Need Help With Event

Last Modified: 2014-05-12
Experts, I am trying to learn about events. I have a class that I am using and I have run into something that i cant figure out. I cannot get the onConnected sub to show up when i instantiate the class. I also want the e.eventargs to have the value of the IPAddress. Can you please help me out here?
Public Class Class2

    Public Delegate Sub EventHandler(ByVal sender As Object, ByVal e As EventArgs)
    Public Event Connected As EventHandler
    Private intIndex As Integer
    Private strIP As String

    Public Property index As Integer
            Return intIndex
        End Get
        Set(value As Integer)
            intIndex = value
        End Set
    End Property

    Public Property ip As String
            Return strIP
        End Get
        Set(value As String)
            strIP = value
            onConnect(New ipPropertyChangedEventArgs(value))
        End Set
    End Property

    Protected Overridable Sub onConnect(e As ipPropertyChangedEventArgs)
        RaiseEvent Connected(Me, e)
    End Sub

    Public Class ipPropertyChangedEventArgs
        Inherits EventArgs
        Private ReadOnly _proposedValue As String
        Public ReadOnly Property ProposedValue() As String
                Return Me._proposedValue
            End Get
        End Property
        Public Sub New(ByVal proposedValue As String)
            Me._proposedValue = proposedValue
        End Sub
    End Class

End Class

Open in new window

Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)


Thanks for the input you were right about defining the events. I figured out how to wire it all together.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.