C
chetsjunk
I am having problems with an inherited class not handling an event for
the class it is inherited from. But it's not constistent, so I'm
guessing the problem is elsewhere in my code. I created the following
small program to test my problem, and this WORKS FINE:
-----
Class BaseClass
Public Event SaidSomething(ByVal WhatWasSaid As String)
Public Sub Talk(ByVal WhatToSay As String)
MsgBox(WhatToSay)
RaiseEvent SaidSomething(WhatToSay)
End Sub
End Class
Class InheritedClass
Inherits BaseClass
Private Sub InheritedClass_SaidSomething(ByVal WhatWasSaid As
String) Handles MyBase.SaidSomething
MsgBox("You just said '" + WhatWasSaid + ".'")
End Sub
End Class
Module Module1
Sub Main()
Dim obj As New InheritedClass
obj.Talk("Hello world.")
End Sub
End Module
-----
Again, that works fine. But in the code below, the event (sub) is never
invoked by the base class. I try stepping through my code line by line
to verify this and I see it run past the line to raise the event, but
the event code never gets run. Here is the code (I cannot post it all
because there is too much, unfortunately... Way too long)
-----
Public Class objDataObject
Public Event FieldValueChanged(ByVal FieldName As String, ByVal
Value As Object)
Default Public Property FieldValue(ByVal FieldName As String) As
Object
Get
return dr(FieldName)
End Get
Set(ByVal Value As Object)
dr(FieldName) = VBtoDB(Value)
RaiseEvent FieldValueChanged(FieldName, Value)
End Set
End Property
End Class
Public Class objVehicle
Inherits objDataObject
Private Sub objVehicle_FieldValueChanged(ByVal FieldName As String,
ByVal Value As Object) Handles MyBase.FieldValueChanged
msgbox FieldName + " was just changed to " + ctype(value,string)
End Sub
End Class
Module Module1
Sub Main()
Dim obj As New objVehicle
objVehicle.FieldValue("x")="abcd"
End Sub
End Module
-----
When the code in Main runs, the fieldvalue property in the base class is
set, but it never raises the event in the inherited class. I cannot see
a difference between this code and the sample that works, except for a
few thousand lines of code in between, which I don't know how it could
affect.
Any ideas are welcome. Thanks.
Chet
the class it is inherited from. But it's not constistent, so I'm
guessing the problem is elsewhere in my code. I created the following
small program to test my problem, and this WORKS FINE:
-----
Class BaseClass
Public Event SaidSomething(ByVal WhatWasSaid As String)
Public Sub Talk(ByVal WhatToSay As String)
MsgBox(WhatToSay)
RaiseEvent SaidSomething(WhatToSay)
End Sub
End Class
Class InheritedClass
Inherits BaseClass
Private Sub InheritedClass_SaidSomething(ByVal WhatWasSaid As
String) Handles MyBase.SaidSomething
MsgBox("You just said '" + WhatWasSaid + ".'")
End Sub
End Class
Module Module1
Sub Main()
Dim obj As New InheritedClass
obj.Talk("Hello world.")
End Sub
End Module
-----
Again, that works fine. But in the code below, the event (sub) is never
invoked by the base class. I try stepping through my code line by line
to verify this and I see it run past the line to raise the event, but
the event code never gets run. Here is the code (I cannot post it all
because there is too much, unfortunately... Way too long)
-----
Public Class objDataObject
Public Event FieldValueChanged(ByVal FieldName As String, ByVal
Value As Object)
Default Public Property FieldValue(ByVal FieldName As String) As
Object
Get
return dr(FieldName)
End Get
Set(ByVal Value As Object)
dr(FieldName) = VBtoDB(Value)
RaiseEvent FieldValueChanged(FieldName, Value)
End Set
End Property
End Class
Public Class objVehicle
Inherits objDataObject
Private Sub objVehicle_FieldValueChanged(ByVal FieldName As String,
ByVal Value As Object) Handles MyBase.FieldValueChanged
msgbox FieldName + " was just changed to " + ctype(value,string)
End Sub
End Class
Module Module1
Sub Main()
Dim obj As New objVehicle
objVehicle.FieldValue("x")="abcd"
End Sub
End Module
-----
When the code in Main runs, the fieldvalue property in the base class is
set, but it never raises the event in the inherited class. I cannot see
a difference between this code and the sample that works, except for a
few thousand lines of code in between, which I don't know how it could
affect.
Any ideas are welcome. Thanks.
Chet