A
String
does not have
Event
s you can watch.
The closest thing you can do is wrap it in a
Property
and raise an
Event
(or
Method
) when you set the
String
.
Public Class MmmSixChangedEventArgs
Inherits System.EventArgs
Private _oldValue As String
Private _newValue As String
Public Sub New(ByVal oldValue As String, ByVal newValue As String)
MyBase.New()
_oldValue = oldValue
_newValue = newValue
End Sub
Public ReadOnly Property OldValue As String
Get
Return _oldValue
End Get
End Property
Public ReadOnly Property NewValue As String
Get
Return _newValue
End Get
End Property
End Class
Public Delegate Sub MmmSixChangedEventHandler(ByVal sender As Object, ByVal e As MmmSixChangedEventArgs)
Public Class TestClass
Public Event MmmSixChanged As MmmSixChangedEventHandler
Private _MMM6 As String
Public Property MMM6 As String
Get
Return _MMM6
End Get
Set(ByVal value As String)
Dim oldValue As String = _MMM6
_MMM6 = value
RaiseEvent MmmSixChanged(Me, New MmmSixChangedEventHandler(value, oldValue)
End Set
End Property
End Class
If you do not want to expose the
Event
to other classes you can simply call a
Private Method
instead. That said, you could also create a
Private Property
. However, if access to
_MMM6
is all
Private
I guess you'd know when it changed and wouldn't need
Event
s.
Hope it helps.
Edit:
Created a custom EventArgs for SA :)