Professional Documents
Culture Documents
First Step : ' Define Class with name "Person" ' Define event sub Public Class Person Private mName As String Private mBirthDate As String Private mID As String Public Event NameChanged(ByVal newName As String)
Public Overridable Property Name() As String Get Return mName End Get Set(ByVal value As String) mName = value RaiseEvent NameChanged(mName) End Set
End Property
End Class
Second Step : ' Insert New Button on your form and change its name to btnok
Third Step : ' double click on the button and write the next codes Public Class Form1 Private Sub OnNameChanged(ByVal newName As String) MsgBox("New name: " & newName) End Sub
Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click Dim p As Person = New Person("Salahudeen") AddHandler p.NameChanged, AddressOf OnNameChanged
Add this statement to call the sub (OnNameChanged) in case of the person name has been changed