Using VB.Net VS 2003 I am getting the following message when I call my 2nd
constructor.
Too many arguments to 'Public Sub New()'.
I have 2 constructors:
**********************************
Public Sub New()
End Sub
Public Sub New(initial As Object)
first = initial
data = initial
End Sub
*********************************
But these are in my Abstract class. If I inherit from my Abstract Class,
does each class have to have its own constructor or can I use the same
constructor as my Abstract class. That doesn't appear to be the case here.
I am trying to set up a class that handles data to/from a database that will
tell me whether the value is null or not, what the inital value was and
whether it has been changed.
So I set up an abstract class that does most of the work and then I will
have a small object for each type of variable (string, integer, boolean,
decimal etc).
So how the classes look at the start is:
*******************************************
' 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
Private _first As Object
Private _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 Sub New()
End Sub
Public Sub New(initial As Object)
first = initial
data = initial
End Sub
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
Private _first As String = "" 'original data
Private _data As String = "" 'current data
End Class
Class BooleanType : Inherits DataType
Private _first As Boolean = False 'original data
Private _data As String = False 'current data
End Class
End Namespace
*******************************************
I am calling it from my program as:
***************************************
Imports DBTypesVB.FtsData
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim temp As New StringType
Dim temp2 As New StringType("The 2nd String")
temp.Data = "This is a test"
End Sub
End Class
***************************************
When I set "temp" it works fine.
When I set "temp2" - I get the error.
It doesn't see the 2nd Constructor.
Do I have to take the constructors out of the Abstract class and put them in
each of the other classes?
Thanks,
Tom 2 1425
Tom,
Constructors are not inherited. You need to create the constructors in any
inherited class.
Kerry Moorman
"tshad" wrote:
Using VB.Net VS 2003 I am getting the following message when I call my 2nd
constructor.
Too many arguments to 'Public Sub New()'.
I have 2 constructors:
**********************************
Public Sub New()
End Sub
Public Sub New(initial As Object)
first = initial
data = initial
End Sub
*********************************
But these are in my Abstract class. If I inherit from my Abstract Class,
does each class have to have its own constructor or can I use the same
constructor as my Abstract class. That doesn't appear to be the case here.
I am trying to set up a class that handles data to/from a database that will
tell me whether the value is null or not, what the inital value was and
whether it has been changed.
So I set up an abstract class that does most of the work and then I will
have a small object for each type of variable (string, integer, boolean,
decimal etc).
So how the classes look at the start is:
*******************************************
' 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
Private _first As Object
Private _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 Sub New()
End Sub
Public Sub New(initial As Object)
first = initial
data = initial
End Sub
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
Private _first As String = "" 'original data
Private _data As String = "" 'current data
End Class
Class BooleanType : Inherits DataType
Private _first As Boolean = False 'original data
Private _data As String = False 'current data
End Class
End Namespace
*******************************************
I am calling it from my program as:
***************************************
Imports DBTypesVB.FtsData
Public Class Form1
Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim temp As New StringType
Dim temp2 As New StringType("The 2nd String")
temp.Data = "This is a test"
End Sub
End Class
***************************************
When I set "temp" it works fine.
When I set "temp2" - I get the error.
It doesn't see the 2nd Constructor.
Do I have to take the constructors out of the Abstract class and put them in
each of the other classes?
Thanks,
Tom
"Kerry Moorman" <Ke**********@discussions.microsoft.comwrote in message
news:BE**********************************@microsof t.com...
Tom,
Constructors are not inherited. You need to create the constructors in any
inherited class.
I thought so, but was hoping that wasn't the case.
Thanks,
Tom
>
Kerry Moorman
"tshad" wrote:
>Using VB.Net VS 2003 I am getting the following message when I call my 2nd constructor.
Too many arguments to 'Public Sub New()'.
I have 2 constructors: ********************************** Public Sub New() End Sub
Public Sub New(initial As Object) first = initial data = initial End Sub *********************************
But these are in my Abstract class. If I inherit from my Abstract Class, does each class have to have its own constructor or can I use the same constructor as my Abstract class. That doesn't appear to be the case here.
I am trying to set up a class that handles data to/from a database that will tell me whether the value is null or not, what the inital value was and whether it has been changed.
So I set up an abstract class that does most of the work and then I will have a small object for each type of variable (string, integer, boolean, decimal etc).
So how the classes look at the start is: ******************************************* ' 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 Private _first As Object Private _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 Sub New() End Sub
Public Sub New(initial As Object) first = initial data = initial End Sub
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 Private _first As String = "" 'original data Private _data As String = "" 'current data End Class
Class BooleanType : Inherits DataType Private _first As Boolean = False 'original data Private _data As String = False 'current data End Class
End Namespace *******************************************
I am calling it from my program as: *************************************** Imports DBTypesVB.FtsData
Public Class Form1 Inherits System.Windows.Forms.Form
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim temp As New StringType Dim temp2 As New StringType("The 2nd String")
temp.Data = "This is a test" End Sub End Class ***************************************
When I set "temp" it works fine. When I set "temp2" - I get the error.
It doesn't see the 2nd Constructor.
Do I have to take the constructors out of the Abstract class and put them in each of the other classes?
Thanks,
Tom This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Amadrias |
last post by:
Hi all,
I am using a class to transport some data over the
network. I then added the attribute to the
class.
My problem is that this class is part of a framework and
that I do not want...
|
by: John Brock |
last post by:
I have a base class with several derived classes (I'm writing in
VB.NET). I want each derived class to have a unique class ID (a
String), and I want the derived classes to inherit from the base...
|
by: Ben Blank |
last post by:
I'm writing a family of classes which all inherit most of their methods and
code (including constructors) from a single base class. When attempting to
instance one of the derived classes using...
|
by: Carl Fenley |
last post by:
I've been programming exclusively in C# for the last few years but am now
working on a project where I am required to write all code in VB.NET.
I'm trying to create a class with multiple...
|
by: Dave A |
last post by:
I have a class that does not have a default constructor. The nature of the class inherently excludes it from having one and to put one in will blatantly misrepresent the object that it is modelling....
|
by: Andrew Backer |
last post by:
Hello,
I am having a problem creating a class dynamically. The class I have
is a base class of another, and the parent class has the constructor
(which takes one argument). The base class...
|
by: =?Utf-8?B?cnZtYWNjb3VudA==?= |
last post by:
It seems the static constructor is supposed to be called, ONLY once for a
particular type. If that's the case, why does the following code throws an
exception?
using System;
using...
|
by: clicwar |
last post by:
A simple program with operator overloading and copy constructor:
#include <iostream>
#include <string>
using namespace std;
class Vector {
private:
float x,y;
public:
Vector(float u, float...
|
by: Rahul |
last post by:
Hi Everyone,
While working with Java, i came across super() which passes values to
base class constructor from derived class constructor. I was wondering
if this could be implemented in c++ by...
|
by: l.s.rockfan |
last post by:
Hello,
how do i have to call an inherited, templated class constructor from the
initializer list of the inheriting, non-templated class constructor?
example code:
template<typename T>...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |