bugs >> Event Inheritance from an Abstract Class Does Not Work in VB2005?

by c29uaWNib29vb20 » Wed, 12 Apr 2006 08:44:01 GMT

I have an abstract (MustInherit) class defined in VB.NET that contains some
public events. To my surprise, my inherited class that fully implements the
the base class can not access the PUBLIC properties from the abstract class!
What is this? Is this some bizarre OOP rule I've broken? It seems like it
should work.


bugs >> Event Inheritance from an Abstract Class Does Not Work in VB2005?

by Ralph » Wed, 12 Apr 2006 13:27:25 GMT





some
the
class!
it

On the surface of what you have said, then there shouldn't be any problem,
as an Abstract class can have both non-implemented and implemented methods.

You need to show some code.

But more importantly you need to post in a 'dotnet' newsgroup as you are
more likely to get a better answer.

--
<response type="generic" language="VB.Net">
This newsgroup is for users of Visual Basic version 6.0
and earlier and not the misleadingly named VB.Net
or VB 200x. Solutions, and often even the questions,
for one platform will be meaningless in the other.
When VB.Net was released Microsoft created new newsgroups
devoted to the new platform so that neither group of
developers need wade through the clutter of unrelated
topics. Look for newsgroups with the words "dotnet",
"framework", or "vsnet" in their name.

For the news.microsoft.com news server try these:


microsoft.public.dotnet.general
microsoft.public.dotnet.languages.vb
microsoft.public.vsnet.general
microsoft.public.vstudio.general
</response>





Similar Threads

1. Need help: about OOP inheritance/abstract class

Hi,

I have a base usercontrol with a method (blank method, no code), I have
another few usercontrols that will inherit this base usercontrol, but I want
to force all the usercontrol that inheriting this base usercontrol to
override the method with its own code. How do I do it?

I have tried to make the base usercontrol an abstract class (mustinherits +
mustoverrides), this works, but all the usercontrols that inherit it will
not able to open in VS designer because of inherting an abstract class.

I have also tried to use interface, this works as well, but I can't force
those usercontrols that inherit base usercontrol MUST have the interface.

Anyone has a solution for this?


Thanks,
Tee


2. Abstract Class inheritance problem - VB.Net

3. Abstract Class inheritance problem

In VS 2003, I am setting up an abstract class that is setting up classes for 
each datatype of VB.Net (as well as C#).

I am trying to set it up so that most of the work is done in the Abstract 
Class.  It seems to work pretty well.  I have the actual data memory 
variables stored as an object as each class will use it as a different type 
of object (not sure if this is a problem).

The system can tell if the variable is a string, boolean or integer pretty 
well by the initial settings.

But it has a problem with decimal, singles and doubles.

When looking at the variables as they are created in the watch window:

*********************************************
        Dim temp As New StringType
        Dim temp2 As New StringType("The 2nd String")
        Dim tempBool As New BooleanType
        Dim tempBool2 As New BooleanType(True)
        Dim tempInteger As New IntegerType
        Dim tempInteger2 As New IntegerType(25)
        Dim tempDecimal As New DecimalType
        Dim tempDecimal2 As New DecimalType(15)
        Dim tempSingle As New SingleType
        Dim TempSingle2 As New SingleType(12.15)
        Dim TempDouble As New DoubleType
        Dim TempDouble2 As New DoubleType(15.23)
**********************************************

The system thinks the variables in the DecimalType class is an integer and 
the variables in the SingleType and DoubleType class are Doubles.

Here is the Class so far:
********************************************
' Create to new variable types to handle nulls and track changes
' to standard variable types.  This is for use with database variables.
' This will tell us if a vaiable has changed, give us the original and 
current value,
' and tell us whether the current value and original value is/was null or 
not.

imports System
imports System.IO

Namespace FtsData
    MustInherit Class DataType
        Protected _first As Object
        Protected _data As Object
        Private _changed As Boolean = False     'value changed from set
        Private nullFirst As Boolean = False    'Was Null at start?
        Private nullData As Boolean = False     'current data null

  Public Function IsNull() As Boolean
   return nullData
  End Function

  Public Function IsFirstNull() As Boolean
   return nullFirst
        End Function

  Public Sub SetNull()
   nullData = true
   _data = ""
  End Sub

  Public Sub SetFirstNull()
   nullFirst = true
   _first = ""
  End Sub

  ' Properties

  Public Property First As Object
      Get
                return _first
            End Get
      Set
                _first = value
            End Set
  End Property

  Public Property Data As Object
      Get
                return _data
            End Get
      Set
                _data = value
                _changed = true
                nullData = false
            End Set
  End Property

  Public Property Changed as Boolean
      Get
                return _changed
            End Get
   Set
                _changed = value
            End Set
        End Property
    End Class

 Class StringType : Inherits DataType

        Public Sub New()
      _first = ""       'original data
      _data  = ""        'current data
        End Sub

  Public Sub New(initial As Object)
   _first = initial
   _data = initial
  End Sub

 End Class

 Class IntegerType : Inherits DataType

        Public Sub New()
      _first = 0   'original data
      _data = 0    'current data
        End Sub

  Public Sub New(initial As Object)
   _first = 0
   _data = 0
  End Sub

 End Class

 Class IntType : Inherits DataType

        Public Sub New()
      _first = 0   'original data
      _data = 0    'current data
        End Sub

  Public Sub New(initial As Object)
   _first = initial
   _data = initial
  End Sub

 End Class

 Class BoolType : Inherits DataType

        Public Sub New()
      _first = False   'original data
      _data = False    'current data
        End Sub

  Public Sub New(initial As Object)
   _first = initial
   _data = initial
  End Sub

 End Class

 Class BooleanType : Inherits DataType

        Public Sub New()
      _first = False   'original data
      _data = False    'current data
        End Sub

  Public Sub New(initial As Object)
   _first = initial
   _data = initial
  End Sub

 End Class

 Class DecimalType : Inherits DataType

        Public Sub New()
      _first = 0   'original data
      _data = 0    'current data
        End Sub

  Public Sub New(initial As Object)
   _first = initial
   _data = initial
  End Sub

 End Class

    Class SingleType :Inherits DataType

        Public Sub New()
      _first = 0.0   'original data
      _data = 0.0    'current data
        End Sub

  Public Sub New(initial As Object)
   _first = initial
   _data = initial
  End Sub
    End Class

    Class DoubleType :Inherits DataType

        Public Sub New()
      _first = 0.0   'original data
      _data = 0.0    'current data
        End Sub

  Public Sub New(initial As Object)
   _first = initial
   _data = initial
  End Sub
 End Class

End Namespace
********************************************

I could initally set them up in the classes, something like:
************************************
    Class DoubleType :Inherits DataType
        Private _first As Decimal
        Private _data As Decimal

        Public Sub New()
      _first = 0.0   'original data
      _data = 0.0    'current data
        End Sub

  Public Sub New(initial As Object)
   _first = initial
   _data = initial
  End Sub
**********************************

But then the Properties in the Abstract class wouldn't be able to access 
them.  Actually as set up here the SetNull and SetFirstNull methods are not 
correct as the variables are not always strings.

Do I have to set each each variable type in each class instead of an object 
in the Abstract class?

If so, is there a way to get the Properties in the Abstract class to access 
them?

Thanks,

Tom 


4. The designer must create an instance (but bae class is not abstract) - VB.Net

5. Event not work with new class that Inherits TreeNode


I define my class as below, I don't need to override the "new(text as
string)" method as it not inherited, but I don't know why.



-------------------

Public Class TreeNode2

    Inherits System.Windows.Forms.TreeNode

    Private m_UID As Integer

    ReadOnly Property HoldData()

        Get

            Return m_UID

        End Get

    End Property



    Sub New(ByVal txt As String, ByVal UID As Integer)

        MyBase.New(txt)

        m_UID = UID

    End Sub

End Class

-------------------



I create an instance of the new class in the code below



--------------------

Dim parentnode As TreeNode2

parentnode = New TreeNode2("1st Tree Node     ", -1)

----------------



I then respond to the event of the treeview, it is at this point I have a
problem as VB.Net says UID is not a member of TreeNode2



-----------------



Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect

        Dim mynode As TreeNode2

        mynode = CType(e.Node, TreeNode2)

        MessageBox.Show(mynode.UID)

End Sub


6. Event will not work when 2 classes are run

7. Class instantiation with variables / abstract classes

Hello,

Using asp with vbscript, can I instantiate a class with a variable, like 
"Set myBook = New Book(id)" and it would get info from the DB, or is it only 
possible to instantiate like "Set myBook = New Book" and then have a method 
like "myBook.loadFromId(id)"?

is it possible in ASP using VBScript to create a class and use it's methods 
without having an instance of the class? So i could do something like 
"Book::getNumberOfBooks()" (using PHP syntax). I believe this is called an 
abstract class, right?

Thanks you!

-M 


8. Inheritance only works if Project based and not File based - VB.Net