Avatar of Basicfarmer
Flag 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
            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

Visual Basic.NETProgramming Languages-Other.NET Programming

Avatar of undefined
Last Comment

8/22/2022 - Mon
Frank Helk

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Thanks for the input you were right about defining the events. I figured out how to wire it all together.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy