Ornez,
Consider the following example: In block one, we have a declaration for
an object of type "AbstractClass", notice how you have to declare it without
the new keyword; we have initialized it with the value of a different class,
one of type "DerivedClass"
AbstractClass doesn't do anything except define the base functionality
(those elements that every derived class will have in common). The rest of
the functions and properties are DEFINED in the Interface. All of the actual
work is performed in the DerivedClass.
To see how this works do the following:
Create a new form, switch to code view, paste all the code in block two at
the very end of the file. Now, switch back to design view, add a button, in
the click event paste the contents of block one. Set a breakpoint on block
one and step through the code to see what happens. Herfried is my Newsgroup
Idol, but, he is way above most of us and it's hard to understand his points
at times. This small example should give you an idea of Inheritenance.
Microsoft has several good webcasts and videos; I recommend watching the
webcasts on Inheritance and Interfaces
http://msdn.microsoft.com/vbasic/atthemovies/ http://msdn.microsoft.com/vbtv/ http://msdn.microsoft.com/showsandwebcasts/default.aspx
Jared
'<Block One>
Dim Abstract As AbstractClass = New DerivedClass
With Abstract
.DoSomething("DoingSomething")
.MyProperty = "Setting the Property of myvalue"
.OnMessage()
End With
'</Block One>
<Block Two>
Public MustInherit Class AbstractClass
Implements MyInterface
MustOverride Function DoSomething(ByVal Something As String) As String
Implements MyInterface.DoSomething
MustOverride Property MyProperty() As String Implements
MyInterface.MyProperty
MustOverride Sub OnMessage() Implements MyInterface.OnMessage
End Class
Public Interface MyInterface
Sub OnMessage()
Function DoSomething(ByVal Something As String) As String
Property MyProperty() As String
End Interface
Public Class DerivedClass
Inherits AbstractClass
Private _mMyproperty As String
Public Overrides Function DoSomething(ByVal Something As String) As
String
MessageBox.Show("Something with a value of: " & Something & "
happened")
End Function
Public Overrides Property MyProperty() As String
Get
Return Me._mMyproperty
End Get
Set(ByVal Value As String)
Me._mMyproperty = Value
End Set
End Property
Public Overrides Sub OnMessage()
MessageBox.Show("OnMessage Handled")
End Sub
End Class
</Block Two>
"Ornez" <Or***@discussions.microsoft.com> wrote in message
news:C8**********************************@microsof t.com...
Hi Jared,
First,thank you for your quick respond.
Let say that Class A has MustOverride Sub OnMessage(ByVal message As
string)
and i need to implement in derived class, to popup a message box when the
sub is called . you wrote "So, your customer can access your
implementation
by instantiating his abstract class with a value of your derived class. "
.What value of my derived Class ?
Thanks
Ornez
"Jared" wrote:
It was supposed to read
Stream = New System.IO.MemoryStream, I think my spell checker got a hold
of
it.
> Stream = New System.IO.Memory