Link to home
Start Free TrialLog in
Avatar of Basicfarmer
BasicfarmerFlag for United States of America

asked on

Need Help With Event

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
        Get
            Return intIndex
        End Get
        Set(value As Integer)
            intIndex = value
        End Set
    End Property

    Public Property ip As String
        Get
            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
            Get
                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

ASKER CERTIFIED SOLUTION
Avatar of Frank Helk
Frank Helk
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Basicfarmer

ASKER

Thanks for the input you were right about defining the events. I figured out how to wire it all together.